I am currently making a shopping basket type script but the user just ticks the checkboxes for the products they want. I just have one problem; that is the php code to check against each checkbox and to see if it's checked. The user orders on a page called order.php I use an MySQL database to store the products unique id, name and price. I use the following code to list all of the available products.
$products_query = "SELECT productid, pname, pprice FROM products";
$products_result = mysql_query($products_query);
$products_rows = mysql_num_rows($products_result);
$products_data = mysql_fetch_array($products_result);
$i=0;
while ($i < $products_rows) {
$productid = mysql_result($products_result,$i,"productid");
$pname = mysql_result($products_result,$i,"pname");
$pprice = mysql_result($products_result,$i,"pprice");
echo("<tr><td colspan=2>$pname ($$pprice) <input type=checkbox name=$productid value=1><br></td></tr>");
$i++;
}
This then displays this for each product:
Product name here ($Price here) Chekbox here
Once the user has checked the products they want they click on a submit button where they are taken to a page called checkout.php Could someone please help me out by giving me some code to use on the checkout.php page to check against each checkbox to see if it is ticked. I have tried many things like the if statement but can't find any to work.