multiple drop downs

From: Date: Wed, 23 Aug 2000 15:29:39 +0000
Subject: multiple drop downs
Groups: php.general 
Request: Send a blank email to php-general+get-13164@lists.php.net to get a copy of this message
Hello again The basic idea of the site is to enable a person to compare 3 vehicles simultaniously according to 2 initial choices ( chassis and price) Frames are used to list the 3 different vehicles. The last code I have at the bottom of this email (main1_active.php) will be replicated for the other 2 frames. Hope this is clearer This is the code for the first page (choose.php), which draws out data for the first drop down lists ( the second only appears once the category 'karosserie' is selected) after the 2 have been selected the variables are sent to the next page choose2.php . ---------------------------------->>> <? mysql_connect ("host", "user",""); mysql_select_db (yelloit); $query="Select distinct karosserie from fahrzeuge"; $result=mysql_query($query); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Yellow-It----Select</title> <script language="JavaScript" > </script> </head> <body marginheight="0" topmargin="0" marginwidth="0" leftmargin="0" onload="init()"> <div style="position: absolute; top: 20; left: 20; width: 625; height: 191; z-index: 4"> <table border="0" width="100%" cellspacing="4" cellpadding="0"> <tr> <td width="100%"> </td> </tr> <tr> <td width="100%"> <form action=<? echo $PHP_SELF ;?> method=post> <select name="karosserie" onChange="submit();"> <?if ($karosserie!="") { ?> <option value=<?echo $karosserie;?>><?echo urldecode($karosserie);?></option> <?}else{?> <option selected>Karosserie</option> <?}?> <?while ($row=mysql_fetch_array($result)) {?> <option value=<?echo ($row['karosserie']);?>><?echo $row['karosserie']?></option> <?}?> </select> <br> <? if ($karosserie!="") { $query="Select distinct listprice from fahrzeuge where karosserie='".urldecode($karosserie)."'"; $priceresult=mysql_query($query); ?> <select name="listprice" onChange="submit();"> <?if ($listprice!="") {?> <option value=<?echo $listprice ;?>><?echo urldecode($listprice);?></option> <?}else{?> <option selected>Price</option> <?}?> <?while ($row=mysql_fetch_array($priceresult)) {?> <option value=<?echo ($row['listprice']);?>><?echo ($row['listprice']);?></option> <?}?> </select> <br> <?}?> </form> </td> <tr> <td width="100%" height="25%"> <form action="choose2.php?karosserie=<?print urlencode($karosserie); ?>&listprice=<?print urldecode($listprice); ?>" method=post> <input type=submit value="go"> <input type=hidden name=karosserie value=<?print $karosserie;?>> <input type=hidden name=listprice value=<?print urldecode($listprice);?>> <a href=choose.php>reset</a> </form> </td> </tr> </tr> </table> </div> </body> </html> ------------------------------------------>>>> choose2.php This is the almost the same as choos.php but it creates 3 drop down and not 2. Once the user has selected the 3 choices ( make,model,listprice) , the variables are sent to the 3rd and final page whihc uses the 3 variables to SELECT the rest of the relveant data associated with the vehicle. -------------------------------------->>>>> </td> </tr> <tr> <td width="100%"> <? mysql_connect ("localhost", "root","")OR DIE("Sorry, Database not available"); mysql_select_db (yelloit); $query="Select marke from fahrzeuge where karosserie='$karosserie' and listprice='$listprice' "; $result=mysql_query($query); ?> <form action="choose2.php?karosserie=<?print $karosserie ?>&listprice=<?print $listprice ?>" method=post> <select name="marke" onChange="submit();"> <?if ($marke!="") { ?> <option value=<?echo $marke;?>><?echo urldecode($marke);?></option> <?}else{?> <option selected>Marke</option> <?}?> <?while ($row=mysql_fetch_array($result)) {?> <option value=<?echo urlencode($row['marke']);?>><?echo $row['marke']?></option> <?}?> </select> <br> <? if ($marke!="") { $query="Select distinct modell from fahrzeuge where karosserie='$karosserie' and listprice='$listprice'"; $modellresult=mysql_query($query); ?> <select name="modell" onChange="submit();"> <?if ($modell!="") {?> <option value=<?echo $modell;?>><?echo urldecode($modell);?></option> <?}else{?> <option selected>Modell</option> <?}?> <?while ($row=mysql_fetch_array($modellresult)) {?> <option value=<?echo urlencode($row['modell']);?>><?echo $row['modell']?></option> <?}?> </select> <br> <?}?> <? if ($modell!="") { $query="Select distinct type from fahrzeuge where karosserie='$karosserie' and listprice='$listprice'"; $typeresult=mysql_query($query); ?> <select name="type" onChange="submit();"> <?if ($type!="") {?> <option value=<?echo $type;?>><?echo urldecode($type);?></option> <?}else{?> <option selected>Type</option> <?}?> <?while ($row=mysql_fetch_array($typeresult)) {?> <option value=<?echo urlencode($row['type']);?>><?echo $row['type']?></option> <?}?> </select> <br> <?}?> </form> </td> <tr> <td width="100%" height="25%"> <form action="main1_active.php?marke=<?print urldecode($marke); ?>&modell=<?print urldecode($modell); ?>&type=<?print urldecode($type);?>" method=post> <input type=submit name=mode value="go"> <input type=hidden name=marke value=<?print $marke;?>> <input type=hidden name=listprice value=<?print urldecode($modell);?>> <input type=hidden name=type value=<?print urldecode($type);?>> <input type=hidden name=show value=no> <a href=choose.php>reset</a> </form> </td> </tr> </table> </div> </body> </html> ------------------------------------------>>>> My problem is that this last page active1_main.php only shows the 3 variables selected and doesn't show the rest. ------------------------------------------->>>>>>>> <? mysql_connect ("localhost", "root",""); mysql_select_db ("yelloit"); $query="SELECT * FROM fahrzeuge WHERE marke='$marke' and modell='$modell'and type='urlencode($type)'"; $result=mysql_query($query); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>yellow-it -- main page (sub frame #1)</title> <link rel="stylesheet" type="text/css" href="../yellow.css"> </head> <body marginheight="0" topmargin="0" marginwidth="0" leftmargin="0" bgcolor="#FFFFFF" text="#000000"> <layer> <p>&nbsp;</p><table border="0" width="100%" cellspacing="4" cellpadding="0"> <tr> <td width="100%" align="center"> <table border="1" width="100%" bordercolor="#000000" cellspacing="0"> <tr> <td width="100%" bgcolor="#FFFFCC" align="left"><? print $modell; ?></td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="left"><? print $marke; ?></td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="left"><? print urldecode($type); ?></td> </tr> <tr> <? $result=mysql_query($query); if ($result) { while ($r = mysql_fetch_array($result)) { $sitze = $r["fahrzeuge.sitze"]; } } ?> <td width="100%" bgcolor="#CCCCCC" align="left"><? print $sizte; ?></td> <?mysql_free_result($result);?> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">&nbsp;</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">&nbsp;</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">&nbsp;</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="left">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> <tr> <td width="100%" bgcolor="#FFFFCC" align="right">blah 1</td> </tr> <tr> <td width="100%" bgcolor="#CCCCCC" align="right">blah 2</td> </tr> </table> </td> <td align="center"><img border="0" src="../images/landrover130crewcab.gif" width="1" height="1"></td> </tr> <tr> <td width="100%" align="center"><img border="0" src="../images/landrover130crewcab.gif" width="1" height="1"></td> <td align="center"><img border="0" src="../images/landrover130crewcab.gif" width="1" height="1"></td> </tr> </layer> </body> </html> ----------------------------------->>>>> I hope this is a bit clearer Gianni

« previous php.general (#13164) next »