Jump to content

using multiple drop down list to query database?


jj0311

Recommended Posts

First I want not say I am not really well versed in programming, and appreciate any help.

 

 

Is it possible to use field values selected from multiple(6) dynamically generated drop down menus on one page to query a database when a button is clicked and then use display the results of the query on another page? If so, what should I do?

 

Also I wanted to allow users to be able to leave fields blank i.e. not select a value from the table for the search...is that possible?

 

Not sure if the code is needed but here is a snipit from the menus and form they are contained in:

 

<form id="search_taste" name="search_taste" method="post" action="tasteNote.php">

  <p>

    <label>Wine

      <select name="Wine" id="Wine" title="<?php echo $row_rs_Wine['WINE_PROPRIETARY_NAME']; ?>">

        <option value="*">All</option>

        <?php

do { 

?>

        <option value="<?php echo $row_rs_Wine['WINE_PROPRIETARY_NAME']?>"><?php echo $row_rs_Wine['WINE_PROPRIETARY_NAME']?></option>

        <?php

} while ($row_rs_Wine = mysql_fetch_assoc($rs_Wine));

  $rows = mysql_num_rows($rs_Wine);

  if($rows > 0) {

      mysql_data_seek($rs_Wine, 0);

  $row_rs_Wine = mysql_fetch_assoc($rs_Wine);

  }

?>

      </select>

    </label>

    </p>

  <p>

      <label>Vintage

  <select name="Vintage" id="Vintage">

    <option value="*">All</option>

    <?php

do { 

?>

    <option value="<?php echo $row_rs_Vintage['WINE_VINTAGE']?>"><?php echo $row_rs_Vintage['WINE_VINTAGE']?></option>

    <?php

} while ($row_rs_Vintage = mysql_fetch_assoc($rs_Vintage));

  $rows = mysql_num_rows($rs_Vintage);

  if($rows > 0) {

      mysql_data_seek($rs_Vintage, 0);

  $row_rs_Vintage = mysql_fetch_assoc($rs_Vintage);

  }

?>

  </select>

    </label>

Hiya mate,

 

It seems to me your looking for a chained drop down box,

 

Ajax is the best to use for this google 'free ajax chained multi drop down box' and you should find what you want,

 

Also if you are only looking to use php maybe use

$_GET[' ']

so show / hide div sections containing the data.

 

James.

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.