I am working on a script that will query the list of all products available for certain photos on my photography website. At this point, the problem is that I am not sure how to place the result into a drop down list that clients can use to select which products they want. Right now, all the products list themselves in a table and it takes up a lot of room. I would like to have the client be able to select the product they want from a drop down menu then be able to press an 'add to cart' button. Here is the portion of code that I am working with:
if($setting->allow_prints == 1){
if($package->update_29 == 0){
echo "<tr><td class=\"photo_details\" bgcolor=\"#000000\" style=\"border: 1px solid #eeeeee; padding: 10px;\">";
echo "<div align=\"center\" style=\"background-color: #000000; margin-bottom: 10px; padding: 3px;\"><b>Purchase Products</b></div>";
$x = 1;
$print_result = mysql_query("SELECT * FROM prints where quan_avail > 0 order by 'porder'", $db);
$print_rows = mysql_num_rows($print_result);
while($print = mysql_fetch_object($print_result)){
echo "<b>" . $print->name . "</b><br>";
//echo "<b>Size:</b> " . $print->size . "<br>";
echo "<font color=\"#CCCCCC\"><b>Price:</b> " . $currency->sign . $print->price . " (each)";
if($print->quan_avail != "999"){
echo "<br />Quantity Available: " . $print->quan_avail;
}
echo "</font><br>";
echo "<span style=\"float: right\"><a href=\"public_actions.php?pmode=add_cart&ptype=p&gid=" . $_GET['gid'] . "&sgid=" . $_GET['sgid'] . "&pid=" . $_GET['pid'] . "&prid=" . $print->id . "\" class=\"photo_links\"><img src=\"images/cart.gif\" valign=\"middle\" border=\"0\"></a> <a href=\"public_actions.php?pmode=add_cart&ptype=p&gid=" . $_GET['gid'] . "&sgid=" . $_GET['sgid'] . "&pid=" . $_GET['pid'] . "&prid=" . $print->id . "\" class=\"photo_links\">Add To Cart</a></span>";
echo "<hr color=\"#ffffff\" size=\"1\"><br>";
}
} else {
$myprod = explode(",",$package->prod);
//$myprod = $package->prod;
foreach($myprod as $value){
if($value != ""){
$newarray[] = $value;
}
}
if(is_array($newarray)){
$id_nums = implode(", ", $newarray);
echo "<tr><td class=\"photo_details\" bgcolor=\"#000000\" style=\"border: 1px solid #eeeeee; padding: 10px;\">";
echo "<div align=\"center\" style=\"background-color: #000000; margin-bottom: 10px; padding: 3px;\"><b>Buy prints</b></div>";
} else {
$id_nums = "999999999999,99999112299999,999991323129";
echo "<tr><td class=\"photo_details\" bgcolor=\"#000000\" style=\"border: 1px solid #eeeeee; padding: 10px;\">";
}
if($package->all_prints){
$print_result = mysql_query("SELECT * FROM prints where quan_avail > 0 order by 'porder'", $db);
} else {
$print_result = mysql_query("SELECT * FROM prints where quan_avail > 0 and id IN ($id_nums) order by 'porder'", $db);
}
$print_rows = mysql_num_rows($print_result);
while($print = mysql_fetch_object($print_result)){
echo "<b>" . $print->name . "</b><br>";
//echo "<b>Size:</b> " . $print->size . "<br>";
echo "<font color=\"#CCCCCC\"><b>Price:</b> " . $currency->sign . $print->price . " (each)";
if($print->quan_avail != "999"){
echo "<br />Quantity Available: " . $print->quan_avail;
$dropdown = '<select>';
}
echo "</font><br>";
echo "<span style=\"float: right\"><a href=\"public_actions.php?pmode=add_cart&ptype=p&gid=" . $_GET['gid'] . "&sgid=" . $_GET['sgid'] . "&pid=" . $_GET['pid'] . "&prid=" . $print->id . "\" class=\"photo_links\"><img src=\"images/cart.gif\" valign=\"middle\" border=\"0\"></a> <a href=\"public_actions.php?pmode=add_cart&ptype=p&gid=" . $_GET['gid'] . "&sgid=" . $_GET['sgid'] . "&pid=" . $_GET['pid'] . "&prid=" . $print->id . "\" class=\"photo_links\">Add To Cart</a></span>";
echo "<hr color=\"#ffffff\" size=\"1\"><br>";
}
}
echo "</td></tr>";
}{
I would appreciate any help I can get. I don't know a whole lot of PHP at this point.