Hello all. Excuse me if the query is so basic. I am writing a script that allows me to take data from a table myql to a lists drop down form to allow to select a product finally and to show its characteristics (not images) and a Link that will be made up of a fixed URL + a code of product (Web Part naumber) to enter to its corresponding webpage. May be, somebody can help me to follow this? Many7 thanks in advance!!!
Im transcribing the code:
<?PHP
$Host = "";
$User = "";
$Passwd = "";
$DBName = "";
$TableName = "";
$Link = mysql_connect($Host, $User, $Passwd) or die("Could not connect: " . mysql_error());
$Link = mysql_connect($Host, $User, $Passwd) or die("Could not connect: " . mysql_error());
$Query = "SELECT Distinct manufacturer ".
"FROM $TableName";
$Result = mysql_db_query( $DBName, $Query, $Link );
?>
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
<!--
function BodyLoad() {
var select = document.FormName.manufacturer;
select.options[0] = new Option("Choose One");
select.options[0].value = 0;
<?PHP
$ctr = 1;
While( $Row = mysql_fetch_array($Result) ) {
echo "select.options[" . $ctr . "] = new Option(\"" . $Row["manufacturer"] . "\");\n";
echo "select.options[" . $ctr . "].value = \"" . $Row['model'] . "\";\n";
$ctr++;
}
?>
}
function Fill_Sub() {
var main_select = document.FormName.manufacturer;
var sub_select = document.FormName.model;
if( main_select.options[main_select.selectedIndex].value != 0 ) {
sub_select.length = 0;
}
<?PHP
$Query = "SELECT Distinct manufacturer ".
"FROM $TableName";
$Result = mysql_db_query( $DBName, $Query, $Link );
while( $Row = mysql_fetch_array($Result) ) {
?>
if( main_select.options[main_select.selectedIndex].text == "<?PHP echo $Row[manufacturer]; ?>" ) {
<?PHP
$Query2 = "SELECT model ".
"FROM $TableName ".
"WHERE manufacturer = '$Row[manufacturer]'";
$Result2 = mysql_db_query( $DBName, $Query2, $Link );
$ctr = 0;
While( $Row2 = mysql_fetch_array($Result2) ) {
echo "sub_select.options[" . $ctr . "] = new Option(\"" . $Row2["model"] . "\");\n";
echo "sub_select.options[" . $ctr . "].value = \"" . $Row['model'] . "\";\n";
$ctr++;
}
?>
}
<?PHP
}
mysql_close($Link);
?>
}
-->
</SCRIPT>
</HEAD>
<BODY onload="BodyLoad();">
<FORM name="FormName" method="POST" action="">
<TABLE border="1">
<TR>
<TD>Manufacturer</TD>
<TD>Model</TD>
</TR>
<TR>
<TD>
<SELECT name="manufacturer" onchange="Fill_Sub();"></SELECT>
</TD>
<TD>
<SELECT name="model" onchange="submit();"></SELECT>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Table:
manufacturer model prefix webpartnumber Suffix Lamp Type Wattage Lamp hours Display Trade Canx
Juan X 15e 1 X 15e Lamp UHP 250 watt, 2000 hour, projector 286,50 y
Pedro X 15i 2 X 15i Lamp UHP 250 watt, 2000 hour, projector 286,50 y
Pedro X 30e 8 X 30e Lamp UHP 250 watt, 2000 hour, projector 286,50
Tito X 30i 7 X 30i Lamp UHP 250 watt, 2000 hour, projector 286,50
Roberto SX 15e 7 SX 15e Lamp UHP 250 watt, 2000 hour, projector 286,50 y
Mamu