I am having problems getting the results from some checkboxes, the result only shows the first checkbox that has been ticked and ignores the others for some reason. I know that the correct values are there because I have printed then to the browser but when I am running through this loop to get the results from the database I only get one match to check.
Any ideas or criticisms are welcomed.
thx
here is the code
Any ideas or criticisms are welcomed.
thx
here is the code
Code:
<?php
if(!empty($_POST['dvd']))
{
include_once("connection.txt");
// select the database
mysql_select_db($theDatabaseName,$conn) or die (mysql_error());
$query = 'SELECT * FROM video';
$querySet = mysql_query($query);
$res = mysql_query($query, $conn);
$numRows = mysql_num_rows($querySet);
$numCols = mysql_num_fields($querySet);
/////////////////////////////////////////////
// Get The table rows and print the customer order but each row will have to be checked
// as many times as there are choices hmmm.. there is probably a simpler way but hey it works!:)
$numResult=0;
$numResult=count($_POST['dvd']);
Print "You Have chosen $numResult DVDs";
foreach ($_POST['dvd'] as $value)
{
//go through the table/array, once for each choice
for ($row = 0; $row < $numRows; $row++)
{
$nextRow = mysql_fetch_row($querySet);
//$temp = $nextRow[0];
//print "this nextrow 0 $nextRow[0]<br>";
if ($value == $nextRow[0])
{ //this is the row in the database that the customer has
//orderd so print to screen so they can check
for ($col = 0; $col < $numCols; $col++)
{
echo $nextRow[$col];
}
}
}
}
////////////////
}
else
{
print "<h1> No Selection made</h1>";
}
//////////////////////////////////////////////////////////////////////////////////////////////////
?>