Forum Moderators: open
For example../The first form is going to contain a List of Area Rug manufacturers such as Milliken, Shaw, and Sphinx. If the user selects Milliken then the second form gets populated with all the collections of the Milliken Manufacturer. If the user selects Shaw then the second form gets populated with all the collections of the Shaw Manufacturer.
The collection List/Menu's are going to be populated by querying a db table using PHP and MySql.
function OnChange()
{ document.form1.select1.options.length=0
var i = 0;
<?php
$dbcnx = @mysql_connect('localhost', 'username', 'password');
@mysql_select_db("table", $dbcnx);
$manufacturers = @mysql_query("Select id, manufacturer from manufacturers");
while ($manufacturer = mysql_fetch_array($manufacturers))
{?>
document.form1.select1.options[i]=new Option(<?php echo $manufacturer['manufacturer'];?>, <?php echo $manufacturer['manufacturer'];?>", true, false)
i = i + 1
<?php
}
?>
}
Is the Syntax correct?
function manuChange(thestuff)
{alert(thestuff);
document.form1.select2.options.length=0
var i = 0
<?php
$dbcnx = @mysql_connect('localhost', 'username', 'password');
@mysql_select_db("table", $dbcnx);
$collections = @mysql_query("Select id, collection from collections where manuID='notsure'");
while ($collection = mysql_fetch_array($collections))
{?>
document.form1.select2.options[i]=new Option("<?php echo "$collection[collection]";?>", "<?php echo "$collection[collection]";?>", true, false)
i = i + 1
<?php
}
?>
}
This is the line that is giving me trouble
$collections = @mysql_query("Select id, collection from collections where manuID='notsure'");
I don't know how to get my JavaScript 'thestuff' variable into the mysql_query statement.
Thanks