Hi,
Help, I need dynamic select options posted when variable is present. In this scenario below options are posted when there are no records. I have up to 25 fields for Size and about 15 for color. Some records only have 2 to 25 entries, some have none.
Ideal solution needed is to print a select box (size and/or color) ONLY when the first field for that select name exists ($row[Size_1] or $row[Color_1]) then print all select options with field data is present.
A solution for this would be much appreciated. I have not been able to locate source code to resolve this. I have posted before with no response, is this possible with php / mysql?
Thanks,
James
<?php
$server = "localhost";
$user = "";
$pass = "";
$database = "";
$conn = mysql_pconnect ($server,$user,$pass);
$select = mysql_select_db("$database")or die ("unable to select db");
$result = mysql_query ("SELECT * FROM TABLE
WHERE ID LIKE '$ID1%'
AND ID LIKE '$ID%'
limit 0,1
");
if ($row = mysql_fetch_array($result)) {
echo "
Cart Product Code... Blah Blah....
\n";
/Here is the problem...
echo "
<FORM NAME=P$row[Cat_No]>
<SELECT NAME=size Size=1>
<option value=\"\">Select Size
<option value='- Size: $row[Size_1]'>$row[Size_1]
<option value='- Size: $row[Size_2]'>$row[Size_2]
<option value='- Size: $row[Size_3]'>$row[Size_3]
<option>_________________________
</SELECT><br>
";
echo "
<SELECT NAME=color Size=1>
<option value=\"\">Select Color
<option value='- Color: $row[Color_1]'>$row[Color_1]
<option value='- Color: $row[Color_2]'>$row[Color_2]
<option value='- Color: $row[Color_3]'>$row[Color_3]
<option>_________________________
</SELECT><br>
\n";
/End of problem..
do {
print ("
Cart Submission Code....
");
} while($row = mysql_fetch_array($result));
} else {print "
<center><b>Sorry, no product records were found!</b></center>
";}
?>