I am doing a product comparison. The product list is generated dynamically from database. Each product listed on the product list has a checkbox, which can be checked for comparing. However, the product id that is checked cannot be passed to next page. Would you please tell me how do I get the product id from the product list page????
many thanks.
Here are the codes:
Product list page---------------------------------------------------
<form action="product_compare.php" method="POST">
<?php
include "../conn.inc";
$sql="select id, product_model_type, product_name, data_rate from product ";
$result=mysql_query($sql);
$row=mysql_num_rows($result);
echo "<table>";
while ($query_data=mysql_fetch_array($result))
{
$id=$query_data['id'];
$product_name=$query_data['product_name'];
$i=1;
echo "<tr><td><input type='checkbox' name='ID$i' value='$id'></td><td><a href='product_list.php?id=$id' target=_blank><font face='Arial' size=2>$product_name</font></a></td><tr>";
$i=$i+1;
}
echo "<tr><td colspan=6 align=right><font face='Arial' size=2><b>Total item(s):$row</font>";
echo "</table>";
echo "<input type='hidden' name='row' value='$row'>";
?>
<p><input type="submit" value="comparison " name="comparison ">
</form>
Product comparsion page---------------------------------------------------
.....
$row=(isset($_POST['row']))?$_POST['row']:chr(0);
for ($i=1;$i<=$row;$i++){
$id[$i]=(isset($_POST['ID$i']))?$_POST['ID$i']:chr(0);
if(isset($_POST['ID$i'])){echo "id=$id[$i]";}
else{echo "nothing";}
}
Winter