Where should I should put my INSERT SQL?
Posted: Tue Jan 11, 2011 2:54 pm
Just a quick question I have a form, couple of drop down boxes, input fields etc.. at the end is the submit button. now my question is should my insert into database sqls go before the submit button inside the form?
out side the form? after the button inside the form?
If by any chance you could give me some advice on the best way to layout my sql that would be great. They are big and go into three tables, at the moment I have them as three seperate queries but I think they must be able to go into one. can someone please help me with the layout and syntax.
here is what the queries look like at the moment:
Thanks. =)
out side the form? after the button inside the form?
If by any chance you could give me some advice on the best way to layout my sql that would be great. They are big and go into three tables, at the moment I have them as three seperate queries but I think they must be able to go into one. can someone please help me with the layout and syntax.
here is what the queries look like at the moment:
Code: Select all
if ($IBselect=$_POST ['IBselect']);
{
//CUSTOMER
$enterCust="INSERT INTO customer(username, password, title, firstName, lastName, address, town, country, postCode, phone, email, dateCust)
VALUES ('$_POST[username]', '$_POST[password]', '$_POST[title]', '$_POST[firstName]', '$_POST[lastName]', '$_POST[address]', '$_POST[town]', '$_POST[country]', '$_POST[postCode]', '$_POST[phone]', '$_POST[email]', 'DATE: Auto CURDATE()', CURDATE()";
$enterCust_query=mysql_query($enterCust)or die(mysql_error());
//CARD
$enterCard="INSERT INTO card(cardNumber, name, expDate, cardID)
VALUES ('$_POST[cardNumber]','$_POST[name]', ' $_POST[expDate]', '$_POST[cardID]')";
$enterCard_query=mysql_query($enterCard);
//BOOKING
$RCenterBook=mysql_query("INSERT INTO booking (custNumber, cardID, rideName, seatNo1, seatNo2, price, price2, dateBook, ID_time_tbl)
VALUES ('$custNumber', '$_POST[cardID]', '$rideName', '$_SESSION[IBextract]', '$_SESSION[IBextract2]', '$IBendPrice1', '$IBendPrice2', 'DATE: Auto CURDATE()', CURDATE()', '$_SESSION[IB_slot_Time]'");
$IBenterBooking_query=mysql_query($IBenterBook);
if (!mysql_query($enterCard, $enterCust, $IBenterBook))
{
die("Error:" .mysql_error());
}
echo "1 record added IB";
}