SQL sending 4 SQL querys at once

Status
Not open for further replies.

exile

Solid State Member
Messages
10
I have to add entrys to 4 tables. If something goes wrong and it gets cut off, the whole database indexing is messed up. how can i process the 4 entrys at once in php?
ill get the code a little later, dont have it with me right now.
 
I'm not sure if this is what you mean, but would something like this work?

$sql = "INSERT INTO table ('field') VALUES ('$value')";
$sql1 = "INSERT INTO table ('field') VALUES ('$value1')";
$sql2 = "INSERT INTO table ('field') VALUES ('$value2')";
$sql3 = "INSERT INTO table ('field') VALUES ('$value3')";

if ((mysql_query($sql, $db)) && (mysql_query($sql1, $db)) && (mysql_query($sql2, $db)) && (mysql_query($sql3, $db))) {

echo "Success";

} else {

echo "Failure";

}
 
Status
Not open for further replies.
Back
Top Bottom