View Full Version : Insterting into more than one table help

08-14-2007, 07:50 AM
So, I was looking online and really couldnt find help how to insert data from a form into different tables.

Example: I want to insert lets say the number 100 into the tables:

drivers:, Sales: and into the sales column in both. If this makes sense than can I get a general idea, I dont need someone to write it all out for me, lol unless you really want to ;)! Anyways I would appreciate the help! Cheers!:thumbsup:

08-14-2007, 10:35 AM
You would simply write more than one SQL statement in your processing script.

//this is pseudo code and you should always validate user input.
$sql = "INSERT INTO drivers (`sales`) VALUES ('$_POST['somefield']')";
$mysql_query($sql) or die(mysql_error());

$sql = "INSERT INTO sales (`sales`) VALUES ('$_POST['somefield']')";
$mysql_query($sql) or die(mysql_error());

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum