and this is the result page you see when you clic the submit button.
PHP Code:
<?php
include_once("db_connection.php");
//////////////////////////////
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>THE 1/24-1/25 database</title>
</head>
<body >
<p align="center"> </p>
<table width="920" border="0">
<tr>
<td width="359"><p class="style5">You will find some TBC. TBC is for "To Be Confirmed". If somebody know the missing information ( TBC ) it will be appreciate to send it to me at this mail: <a href="mailto:info@hobby-shop.qc.ca">info@hobby-shop.qc.ca</a> <br />
<br />
thanks in advance for your help</p>
</td>
<td width="161"><div align="center"><a href="search-db-foreach.php"><img src="catalog/images/design_web/othersearch.jpg" border="0" alt="search" width="150" height="96"></a></div></td>
<td width="386"> <div align="right">
<p>This logo <img src= 'http://www.scale24-25.com/catalog/images/design_web/PDF_logo.gif' alt="" width='50' height='50'/> mean that you can download a PDF file. To read it you need minimum Acrobat reader and you can download it <a href="http://get.adobe.com/reader/">here</a></p>
<p>Some link will return a TBC. Sorry for any inconveniant. as soon as we will receive or do the PDF it will be updated.</p>
</div></td>
</tr>
</table>
<br>
<?php
if (isset($_POST['todo']) && $_POST['todo'] == "search") { $todo=$_POST['todo'];
$name=$_POST['manufacturer_reel'];
$name1=$_POST['manufacturer_kit'];
$name2=$_POST['year_prod_reel'];
$name3=$_POST['scale'];
//-query the database table for the post field
$sql="SELECT kit_id, kit_number, kit_name, description_eng, manufacturer_kit, manufacturer_reel, scale, engine_detail, year_prod_kit, year_prod_reel, image_id, image_id1, image_id2 FROM kit ";
$sqlOperand="WHERE";
if ($name != "reel manufacturer") {
$sql = $sql . $sqlOperand . " manufacturer_reel LIKE '%" . $name ."%' ";
$sqlOperand = " AND ";
}
if ($name1 != "kit manufacturer") {
$sql = $sql . $sqlOperand . " manufacturer_kit LIKE '%" . $name1 ."%' ";
$sqlOperand = " AND ";
}
if ($name2 != "vehicules year manufactured") {
$sql = $sql . $sqlOperand . " year_prod_reel LIKE '%" . $name2 ."%' ";
$sqlOperand = " AND ";
}
if ($name3 != "scale") {
$sql = $sql . $sqlOperand . " scale LIKE '%" . $name3 ."%' ";
$sqlOperand = " AND ";
}
if ($sqlOperand == "WHERE") {
echo "<p>Please enter a search query</p>";
}
else {
// echo '<img src="web-design/sorry.jpg" alt="sorry">';
// echo "Sorry nothing match your selection / Desolle rien ne correspond a votre selection";
// echo "run sql: <BR> $sql <BR> and display results";
}
//-run the query against the mysql query function
$result=mysql_query($sql);
//-make the header of the table
echo " <table align=center width=\"1340\" border=\"\">\n";
echo " <tr>\n";
echo" <td nowrap align=center width='95'> kit manufacturer \n";
echo" <td nowrap align=center width='55'> scale \n";
echo" <td nowrap align=center width='90'> kit number \n";
echo" <td nowrap align=center width='290'> kit name \n";
echo" <td nowrap align=center width='400'> description \n";
echo" <td nowrap align=center width='125'> vehicule year \n";
echo" <td nowrap align=center width='80'> complete engine detail\n";
echo" <td nowrap align=center width='80'> Select Picture to get bigger\n";
echo" <td nowrap align=center width='75'> instruction sheet\n";
echo" <td nowrap align=center width='75'> box contain\n";
echo " <tr>\n";
//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){
$description_eng=$row['description_eng'];
$manufacturer_kit=$row['manufacturer_kit'];
$scale=$row['scale'];
$manufacturer_reel=$row['manufacturer_reel'];
$kit_id=$row['kit_id'];
$kit_number=$row['kit_number'];
$kit_name=$row['kit_name'];
$engine_detail=$row['engine_detail'];
$year_prod_reel=$row['year_prod_reel'];
$image_id=$row['image_id'];
$image_id1=$row['image_id1'];
$image_id2=$row['image_id2'];
//-create table of item during he while loop
echo " <table align=center width=\"1340\" border=\"\">\n";
echo" <td nowrap align=center width='95'> $manufacturer_kit \n";
echo" <td nowrap align=center width='55'> $scale \n";
echo" <td nowrap align=center width='90'> $kit_number \n";
echo" <td nowrap align=center width='290'> $kit_name \n";
echo" <td nowrap width='400'> $description_eng \n";
echo" <td nowrap align=center width='125'> $year_prod_reel \n";
echo" <td nowrap align=center width='80'> $engine_detail \n";
if(!empty($image_id)) echo" <td nowrap width='80'> <a href= ".$image_id." target='_blank'> <img src= '".$image_id."' width='75' height='50' border='0'/>";else echo " <td nowrap width='75'> <img src='http://www.scale24-25.com/catalog/images/design_web/tbc.jpg' width='50' height='50' border='0'/>";
if(!empty($image_id1)) echo" <td nowrap width='75'> <a href= ".$image_id1." target='_blank'> <img src='http://www.scale24-25.com/catalog/images/design_web/PDF_logo.gif' width='50' height='50' border='0'/>";else echo " <td nowrap width='75'> <img src='http://www.scale24-25.com/catalog/images/design_web/tbc.jpg' width='50' height='50' border='0'/>";
if(!empty($image_id2)) echo" <td nowrap width='75'> <a href= ".$image_id2." target='_blank'> <img src='http://www.scale24-25.com/catalog/images/design_web/PDF_logo.gif' width='50' height='50' border='0'/>";else echo " <td nowrap width='75'> <img src='http://www.scale24-25.com/catalog/images/design_web/tbc.jpg' width='50' height='50' border='0'/>";
echo " </tr>\n";
echo " </table>\n";
echo " </tr>\n";
echo " </table>\n";
}
}
else{
echo "<p>Please enter a search query</p>";
}
?>
</body>
</html>
now from these file I want to add a second drop down undert the Name Of vehicule manufacturer. this drop down will auto populate with the model found in the database attached to the manufacturer EX: you select chevy and it will found every model of chevy and display them like impala, caprice etc..
I found on the web this... http://roshanbh.com.np/2007/12/chang...x-and-php.html
it's exactly what I want to do so I try it by changing his value by mine but ... it doesn't work.
here is what I've done.
first I create the model database where I put all the model I have
after i create search_model.php like they do (city.php)
her's the code
PHP Code:
<?php
include_once("db_connection.php");
//////////////////////////////
?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$query="select distinct model from model where modelid=$model";
$result=mysql_query($query);?>
<select name="model">
<option>Select Model</option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value><?=$row['model']?></option>
<? } ?>
</select>
</body>
</html>
and than I modify my first page and this is where I stuck for now. I got an error message saying
so my modify code are like this ( I put only the section I modify )
PHP Code:
// strat of drop down ///
$q=mysql_query("SELECT DISTINCT manufacturer_reel FROM kit ORDER BY manufacturer_reel");
echo '<select name="manufacturer_reel" nChange="getModel('search_model.php?model='+this.value)">
<option value="reel manufacturer">Please Choose an Option</option>';
while($row = mysql_fetch_array($q)) {
$thing = $row['manufacturer_reel'];
echo '<option>'.$thing.'</option>';
}
echo "</select>";
// end of 1st drop down ///
echo " <br> \n";
echo " <br> \n";
// start of 2nd drop down ///
?>
<div id="modeldiv"><br /><br />
<select name="select">
<option>Select Model</option>
</select>
this is the error message I got
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in ....search-db-foreach.php on line 120
the the line 120 is this one
PHP Code:
echo '<select name="manufacturer_reel" nChange="getModel('search_model.php?model='+this.value)">
so what's I've done wrong ?
thanks in advance
S
Bookmarks