SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Advanced Search

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Advanced Search

    Hello before all.

    Ive got this search box:



    Code:
      $info_box_contents = array();
      $info_box_contents[] = array('form' => tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'),
                                   'align' => 'center',
                                   'text' => tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px"') . '&nbsp;' . tep_hide_session_id() . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . BOX_SEARCH_TEXT . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>');
    
      new infoBox($info_box_contents);
    And i would need this:



    Ive got into db a "propertype" table with some property types, and a "location" table with some locations too.
    How can i query property type and location to make a list, and use it to search?

    Thank you in advance.
    Regards.

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    There are two ways of doing this: -

    a) On onchange event of drop down property type drop down refresh the page and depending upon the type selected populate the locations drop down.

    b) Make JavaScript arrays for all the locations of all the property types and OnChange event of property type drop down just refresh the list of values in the location drop down picked from the respective array.

    Second one is a better option as it will not reload the complete page.

    Hope this helps,

    Cheers,
    Maneet Puri
    Lexolution IT Services

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thank you your answer, first of all.

    Your answer is so interesting but I dont need to make locations list from property type because i will receive both data from sql. I mean, when you load page both lists will be already complete, and user only will select one or two selection(s), doing search after.

    Thanks again.

    Regards.

  4. #4
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    from what i can understand
    ...ajax is your fren for this
    this might help
    http://www.w3schools.com/PHP/php_ajax_database.asp

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I am not positive, but I think the OP wants to make a sql query builder, something that reacts to the decisions made on the first screen.

    If so, this post should shed a bit of light on the solution, as might this one.

    Be careful to read up on sql injection before you go public with it though, and come back if you cannot get the logic to work correctly - be prepared to show us your database schema though.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your answers.
    I have made this changes:

    Code:
    <!-- search //-->
              <tr>
                <td class="smallText">
    <?php
      $info_box_contents = array();
      $info_box_contents[] = array('text' => BOX_HEADING_SEARCH);
    
      new infoBoxHeading($info_box_contents, false, false);
    
      $info_box_contents = array();
      $info_box_contents[] = array('form' => tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'));
    
        $propertype_query = tep_db_query("select propertype_id, propertype_name from " . propertype . " order by propertype_name");
        while ($propertype = tep_db_fetch_array($propertype_query)) {
          $propertype_array[] = array('id' => $propertype['propertype_id'],
                                         'text' => $propertype['propertype_name']);
        }
    
        $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
        while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
          $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
                                         'text' => $manufacturers['manufacturers_name']);
        }
    echo "<br>";
      $info_box_contents = array();
      $info_box_contents[] = array('form' => tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'));
      echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_pull_down_menu('propertype_id', $propertype_array, $pInfo->propertype_id);
    echo "<br>";
    echo "<br>";
      echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id);
      echo '&nbsp;' . tep_hide_session_id() . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . '' . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>';
    
    ?>
    <!-- search_eof //-->
    and ive got this:



    Now i will try to link with advanced_search.php sending user's selection(s), i will appreciate any suggestion.
    I would need to take user's selection(s) and make search after that.

    Regards.
    Last edited by akenateb; Nov 17, 2008 at 08:31.

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, i have changed some lines:

    Code:
    <!-- search //-->
              <tr>
                <td class="smallText">
    <?php
    
        $propertype_query = tep_db_query("select propertype_id, propertype_name from " . propertype . " order by propertype_name");
        while ($propertype = tep_db_fetch_array($propertype_query)) {
          $propertype_array[] = array('id' => $propertype['propertype_id'],
                                         'text' => $propertype['propertype_name']);
        }
    
        $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
        while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
          $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
                                         'text' => $manufacturers['manufacturers_name']);
        }
    
      $info_box_contents = array();
      $info_box_contents[] = array('text' => BOX_HEADING_SEARCH);
    
      new infoBoxHeading($info_box_contents, false, false);
    
      $info_box_contents = array();
      $info_box_contents[] = array('form' => tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'),
      'text' => tep_draw_pull_down_menu('keywords', $propertype_array, $pInfo->propertype_id). '&nbsp;' . tep_hide_session_id() . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . '' . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>');
    
      //$info_box_contents = array();
      //'text2' => tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id);
    
    new infoBox($info_box_contents);	
    
    ?>
    <!-- search_eof //-->
    And now ive got this:



    It seems it works.
    Now i will try to add second list to make an advanced search with two keywords.

    Regards.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •