Where to start.....well let's see. I'm sort of making a very simple version of a "shopping cart system". Now I have my product list, and ive added checkboxes next to each product with the value of their own product ID to the value of the checkbox.
What I want to do is to have all the checked boxes neatly into the next page where I can
- draw the ID's out and grab data out of my db with the extracted ID's.
but more importantly
2. put the data in a new table that functions like a "cart".
My friend (who's pretty good with php) couldn't figure out what's wrong with the edited script (I started off pretty messy, and he was "fixing" it).
So while the input of the checkboxes could be read (through the means of echoing parts of the receiving script), I'd get a blank output when I'm really trying to extract the data out of my db.
Here's the code for the output, hope someone can help. And if not, still thanx for reading so far.
<?
include("connect.php");
$keuzearray = $_POST['keuzearray'];
$result = mysql_query("SELECT Naam, Product_ID FROM product")or die(mysql_error());
echo "<table width=100%>";
while($row = mysql_fetch_object($result))
{
echo "Row: ".$row->Product_ID;
if(in_array($row->Product_ID, $keuzearray))
{
echo "<tr>";
echo "<td>Productnummer: ".$row->Product_ID."</td>";
echo "<td>Naam: ".$row->Naam."</td>";
echo "</tr>";
}
}
echo "</table>";
print_R($keuzearray);
?>
For this example I marked the 5th checkbox from the 5 created and this was the output of the test echos
The output of the echo "Row: ".$row->Product_ID;
is this: Row: 1Row: 2Row: 3Row: 4Row: 5
And the output for the print_R($keuzearray);
is this: Array ( [0] => 5 )
I have also confirmed that the table name and the table fields are spelled correctly (and yes, that does include upper/lower case).
So hope someone can tell me why I'm not getting the data out of the query. It doesn't give any errors or anything