PDA

View Full Version : php downdown menu? (newb)



JustinJAH
10-02-2008, 03:13 AM
Im trying to make a search that will search my table for make and model.
Just have a simple drop down menu that will have make then if you click say BMW the next drop down menu beside it will change to BMW Models like a M6.
here is what i have so far

<?
include("connect.php");

$query="SELECT * FROM cars ";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();
<form method="post">

<select name="make">

$sql="SELECT make, model FROM cars GROUP BY make";
$result2=mysql_query($sql);
while ($row2=mysql_fetch_array($result2)) {
?>
<option value="<?=$row2["make"]?>"><?=$row2["make"]?></option>
<?
}
?>
</select>
<input name="makesubmit" type="submit" value="Go" />

<? if(isset($_POST[makesubmit])){ ?>

<select name="make">
<?
$sql="SELECT model FROM cars where make=".$_POST[make];
$result2=mysql_query($sql);
while ($row2=mysql_fetch_array($result2)) {
?>
<option value="<?=$row2["model"]?>"><?=$row2["model"]?></option>
<?
}
?>
</select>


} ?>