Search the Community
Showing results for tags 'dependable'.
-
Hello all! First, im very new to this forum.. and i'm really liking it! Second, i'm having this problem. I created this php dropdown menu allowing a user to select a specific phone make, model, color, size, and condition. However, when i run the script i only get the two makes i initialize within the code "Apple" and "Samsung." Can someone take a look at my code and see if its the issue? My back end looks like so: Database name: model MODEL_ID int(11) Key - Auto increment MAKE_ID int(11) MODEL_NAME varchar(30) Database name: color COLOR_ID int(11) Key - Auto increment MODEL_ID int(2) COLOR_NAME varchar(20) Database name: size SIZE_ID int(11) Key -Auto increment COLOR_ID int(2) SIZE_NAME varchar(40) Database name: con CON_ID int(11) Key -Auto increment SIZE_ID int(2) CON_NAME varchar(20) <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_custsqlmoo16 = ""; $database_custsqlmoo16 = ""; $username_custsqlmoo16 = ""; $password_custsqlmoo16 = ""; $custsqlmoo16 = mysql_pconnect($hostname_custsqlmoo16, $username_custsqlmoo16, $password_custsqlmoo16) or trigger_error(mysql_error(),E_USER_ERROR); ?> <?php $make = $model = $color = $size = $con = null; //declare vars $conn = mysql_connect('localhost'); $db = mysql_select_db('testing',$conn); if(isset($_GET["make"]) && is_numeric($_GET["make"])) { $make = $_GET["make"]; } if(isset($_GET["model"]) && is_numeric($_GET["model"])) { $model = $_GET["model"]; } if(isset($_GET["color"]) && is_numeric($_GET["color"])) { $color = $_GET["color"]; } if(isset($_GET["size"]) && is_numeric($_GET["size"])) { $size = $_GET["size"]; } if(isset($_GET["con"]) && is_numeric($_GET["con"])) { $con = $_GET["con"]; } ?> <script language="Javascript"> function autoSubmit() { var formObject = document.forms['theForm']; formObject.submit(); } </script> <form name="theForm" method="get"> <select name="make" onchange="autoSubmit();"> <option value="null"></option> <option value="1" <?php if($make == 1) echo " selected"; ?>>Apple</option> <option value="2" <?php if($make == 2) echo " selected"; ?>>Samsung</option> </select> <br><br> <?php if($make != null && is_numeric($make)) { ?> <select name="model" onchange="autoSubmit();"> <option value="null"></option> <?php //POPULATE DROP DOWN MENU WITH model FROM A GIVEN make $sql = "SELECT MODEL_ID, MODEL_NAME FROM model WHERE MAKE_ID = $make"; $model = mysql_query($sql,$conn); while($row = mysql_fetch_array($model)) { echo ("<option value=\"$row[MODEL_ID]\" " . ($model == $row["MODEL_ID"] ? " selected" : "") . ">$row[MODEL_NAME]</option>"); } ?> </select> <?php } ?> <br><br> <?php if($model != null && is_numeric($model) && $make != null) { ?> <select name="color" onchange="autoSubmit();"> <option value="null"></option> <?php //POPULATE DROP DOWN MENU WITH COLORS FROM A GIVEN MAKE, MODEL $sql = "SELECT COLOR_ID, COLOR_NAME FROM color WHERE MODEL_ID = $model "; $color = mysql_query($sql,$conn); while($row = mysql_fetch_array($color)) { echo ("<option value=\"$row[color_ID]\" " . ($color == $row["COLOR_ID"] ? " selected" : "") . ">$row[color_NAME]</option>"); } ?> </select> <?php } ?> <br><br> <?php if($color != null && is_numeric($color) && $make != null && $model != null) { ?> <select name="size" onchange="autoSubmit();"> <option value="null"></option> <?php //POPULATE DROP DOWN MENU WITH SIZES FROM A GIVEN MAKE, MODEL, COLOR $sql = "SELECT SIZE_ID, SIZE_NAME FROM SIZE WHERE COLOR_ID = $color "; $size = mysql_query($sql,$conn); while($row = mysql_fetch_array($size)) { echo ("<option value=\"$row[size_ID]\" " . ($size == $row["SIZE_ID"] ? " selected" : "") . ">$row[size_NAME]</option>"); } ?> </select> <?php } ?> <br><br> <?php if($size != null && is_numeric($size) && $make != null && $model != null && $color != null) { ?> <select name="con" onchange="autoSubmit();"> <option value="null"></option> <?php //POPULATE DROP DOWN MENU WITH CONDITIONS FROM A GIVEN MAKE, MODEL, COLOR, SIZE $sql = "SELECT CON_ID, CON_NAME FROM CON WHERE SIZE_ID = $size "; $con = mysql_query($sql,$conn); while($row = mysql_fetch_array($con)) { echo ("<option value=\"$row[CON_ID]\" " . ($con == $row["CON_ID"] ? " selected" : "") . ">$row[CON_NAME]</option>"); } ?> </select> <?php } ?> </form> Thanks ahead of time!
- 1 reply
-
- dynamic
- dependable
-
(and 3 more)
Tagged with: