View Single Post
Old 02-19-2009, 08:14 PM   #1
inflict
 
Join Date: Feb 2009
Posts: 3
Default Creating Dynamic Dropdowns Tut Error

Having a problem with the selecting the make. I think it has to do with my java code but can't figure it out. The error shows:
Notice: Undefined index: make in C:\Documents and Settings\ryan\My Documents\Web Root\Test\dropdown.php on line 4

The make selection won't stay selected but the model section changes when you select the make. Anyone catch what I have wrong?

Code:

PHP Code:
<?php
require_once("Connections/connection.php");
 
$make    =    $_POST['make'];
 
 
if (
$make){
///////////////////////
$query    sprintf("SELECT * FROM car_model where car_model_id='$make'");
$result    = @mysql_query($query);
$rowModel    mysql_fetch_array($result);
/////////////////////////
}
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
 
<body>
 
<form id="form1" name="form1" method="post" action="dropdown.php">
 
 
  <select name="make" onChange="document.forms[0].submit()">
    <option value="" selected>Select Make</option>
    <option value="1">Alfa Romero</option>
    <option value="2">Audi</option>
    <option value="3">BMW</option>
    <option value="4">Citroen</option>
  </select>
 
   <select name="model">
    <option value="">Select Model</option>
    <?php do {     ?>
    <option value="<?php echo $rowModel['car_model_id']; ?>"><?php echo $rowModel['car_model']; ?></option>
    <?php    }while ($rowModel mysql_fetch_array($result)); ?>
  </select>
 
 
</form>
</body>
</html>

Last edited by davidj; 02-19-2009 at 08:57 PM..
inflict is offline   Reply With Quote