Hi,
I could display
Product Name drop down box,
Design ID drop down box, and could list
Property Names. Initially, the php page displays:
Product Name drop down box (works)
Design ID drop down box (works, i.e., upon selection of Product Name corresponding Design ID values are displayed in this box)
Lists all available property names from property table (Doesn't work)
Issue: Initially, all Property Names are displayed. But upon selection of Design ID, the list disappears. Instead it should display the Property Names applicable to the selected Design ID.
Here's my code:
<?php
$dbservertype='mysql';
$servername='localhost';
$dbusername='root';
$dbpassword='';
$dbname='templetree';
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
?>
<!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>
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.products.options[form.products.options.selectedIndex].value;
self.location='design_form_working.php?products=' + val ;
}
function reload3(form)
{
var val=form.products.options[form.products.options.selectedIndex].value;
var val2=form.design.options[form.design.options.selectedIndex].value;
self.location='design_form_working.php?products=' + val + '&design=' + val2 ;
}
</script>
</head>
<body>
<?php
$quer2=mysql_query("SELECT * FROM products");
@$products=$_GET['products'];
if(isset($products)){
$quer=mysql_query("SELECT * FROM sample_design WHERE product_ID=$products");
}else{$quer=mysql_query("SELECT * FROM sample_design"); }
@$design=$_GET['design'];
if(isset($design)){
$quer3="SELECT * FROM sample_design, design_detail, property WHERE sample_design.product_ID=design_detail.product_ID AND design_detail.property_ID=property.property_ID AND design_detail.design_ID=$products";
$result = mysql_query($quer3) or die(mysql_error());
}else{$quer3="SELECT * FROM property";
$result = mysql_query($quer3) or die(mysql_error());}
?>
<form name="f1" method="post" action="dd-check.php">
<?php
echo "<br><select name='products' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['product_ID']==@$products){echo "<option selected value='$noticia2[product_ID]'>$noticia2[product_name]</option>"."<BR>";}
else{echo "<option value='$noticia2[product_ID]'>$noticia2[product_name]</option>";}
}
echo "</select>";
echo "<br><br><br><select name='design' onchange=\"reload3(this.form)\"><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) {
if($noticia['design_ID']==@$design)
{echo "<option selected value='$noticia[design_ID]'>$noticia[design_ID]</option>"."<BR>";}
else{echo "<option value='$noticia[design_ID]'>$noticia[design_ID]</option>";}
}
echo "</select>"."<BR>"."<BR>";
while($noticia = mysql_fetch_array($result)) {
echo "<BR>"."$noticia[property_name]"."<BR>";
}
echo "<BR>"."<BR>"."<input type=submit value=Submit>";
?>
</form>
</body>
</html>
Please help!