Hey there!
Your tutorial has really helped me so far... but i am sort of wondering something: can you do more than one 'INSERT' at the same time to the same table and same database? If so, how do you do the connection? Once at the beginning or everytime? Do you have to do a new query everytime too?
Here is my code.. i have a few if-statements depending on which and if a product has been chosen. I want to inserta new row for every if-statement. But i can't get it to work..
Would appreciate any help i can get..
Cynthia
(cynno410@student.liu.se)
<?php
$DBhost = "*****";
$DBuser = "*****";
$DBpass = "******";
$NameofDB = "******";
$Table = "bestallning_info";
$product = $_POST["chosen_product"]; //"chosen_produkt" is a //checkbox.. there is 5 of them on my site that can all be chosen at the same time, of course.
$temp = $_POST["amout"];
$input1 = ltrim($temp);
$temp2 = $_POST["amount2"];
$input2 = ltrim($temp2);
$temp3 = $_POST["amount3"];
$input3 = ltrim($temp3);
$temp4 = $_POST["amount4"];
$input4 = ltrim($temp4);
$temp5 = $_POST["amount5"];
$input5 = ltrim($temp5);
$order_id = $t;
//$produkt_id;
if ($product == "gron_randig"){
mysql_connect($DBhost, $DBuser, $DBpass) or die("Unable to connect to database");
@mysql_select_db($NameofDB) or die("Unable to select $NameofDB");
$t ='1';
$produkt_id1 ='100301';
$sqlquery = "INSERT INTO $Table VALUES ('$t','$input1','$produkt_id1')";
$results = mysql_query($sqlquery);
mysql_close();
}
if ($product == "rod_randig"){
mysql_connect($DBhost, $DBuser, $DBpass) or die("Unable to connect to database");
@mysql_select_db($NameofDB) or die("Unable to select $NameofDB");
$t ='1';
$produkt_id2 ='100302';
$sqlquery2 = "INSERT INTO $Table VALUES ('$t','$input2','$produkt_id2')";
$results2 = mysql_query($sqlquery2);
mysql_close();
}