Forum > Serverside Modding

[SOLVED] Multiple INSERT INTO queries in one MySQL result

(1/1)

Cuana:
Hi,

I'm currently working on a CMS for the Trinity World DB. I'm kind of new to PHP/SQL and am seeking a simple explanation for executing multiple queries at once!

Currently I am able to insert data into the creature_template database using a HTML form. This works fine as there's only one table where data needs to be inputed.

However when it comes to quests - i have no problem entering data into the quest_template table. However in order to link the quest to an NPC (start/finish) it requires the creature_questrelation, and creature_involved relation table.

So I need to take data from one form and the input the data into appropriate tables.


So far I have:



--- Quote ---$sql="INSERT INTO creature_template (...)
VALUES (...) ";

$result = mysql_query($sql);

if($result){
header("Location: 1a_success.php#show");
}

else {
(will link error page here)
}


--- End quote ---

I need something like

$result = mysql_query($sql1, $sql2, sql3) and then have 3 queries than run. If all 3 queries are successful then I need it to redirect to a success page.

Any ideas? Thanks!

schlumpf:

--- Code: ---$result_a = mysql_query ($query_a);
$result_b = mysql_query ($query_b);
$result_c = mysql_query ($query_c);
if ($result_a && $result_b && $result_c)
{
   // ...
}
else
{
   die ("one of the three queries did not succeed");
}
--- End code ---

Cuana:
Thank you Schlumpf, for that haste response! I never imagined it being quite so straightforward. Something so simple has been holding me back for quite a while. I must admit, I spent time on different days trying to get another piece of the site to work - and in the end it turned out I'd used a "_" somewhere I shouldn't have, and ended up being treated as a wildcard (I think).

Thanks!

/Cuana

Navigation

[0] Message Index

Go to full version