...

View Full Version : drop down filter



Hitman
03-17-2007, 01:25 PM
hi, can anyone here help me how can i do a sequential filtering. here's what I want to happen with my php code... when i select a region to my drop down menu it will display its list of province into another drop down menu. please advice...

here is my code;



<td colspan="3"><select name="region" id="region">


<?php

include("dbconnect.php");

$position1 = mysql_query("SELECT regionid, regionname FROM region ORDER BY regionname");

while($row = mysql_fetch_array($position1, MYSQL_NUM)) {

echo "<option value=\"$row[0]\">$row[1]</option>\n";

}

?>

</select></td>
</tr>
<tr>
<td width="117" height="37"><div align="right"><strong>Province</strong></div></td>
<td>&nbsp;</td>
<td colspan="3"><select name="province" id="province">

<?php

include("dbconnect.php");

$position1 = mysql_query("SELECT provincialid, provincename FROM province ORDER BY provincename");

while($row = mysql_fetch_array($position1, MYSQL_NUM)) {

echo "<option value=\"$row[0]\">$row[1]</option>\n";

}

?>

</select></td>

Hitman
03-18-2007, 08:03 AM
please could somebody here help me

Fou-Lu
03-18-2007, 09:45 AM
You can generate the list of information you need, but to dynamically populate the combo or list box without reloading requires javascript.
Populate the data that you want the onchange behaviour to use, and pass the array into javascript when the page is processed.
PHP is not capable of dynamically creating information on the fly. It is a server side language, and once the page has been parsed and sent to the browser, the php job is done.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum