I am making a simple order form with 5 products and they can be select with a checkbox from the user and then I want to add the products that the visitors will select into mysql database, but as you know for example INSERT array[] doest work!
I made an FOR stamtment with php but it adds only the last product of an array!
I know a way the serialize and unserialize php functions but I dont really like it!
Thank you for your help.
Here is the code:
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$products = $_POST['products'];
$email = $_POST['email'];
echo '<h3>Sehr geehrte/er '.$firstname.' '.$lastname.'</h3>';
if(empty($products))
{
echo("Keine bestellung.");
}
else
{
$N = count($products);
echo("Sie haben $N produkte bestellt:<br /> ");
for($i=0; $i < $N; $i++)
{
echo $order = ($products[$i]);
}
$query = "INSERT INTO salt_orders (products, vorname, nachname, date)
VALUES ( '$order', '$firstname', '$lastname', NOW())";
$result = mysql_query($query);
}