Reputation: 3
I was wondering how do I update two tables using mysql and php?
How would I add the second table to the code?
Here is the code below.
$dbc = mysqli_query($mysqli,"UPDATE tags SET count='$tag_info_count' WHERE id='$tag_info_id'")
Upvotes: 0
Views: 542
Reputation: 4743
check out Execute Multiple MySQL Queries from One String in PHP.
Otherwise, write separate query statements in your PHP.
Upvotes: 0
Reputation: 53861
You create a transaction. I forget the transaction syntax for mysqli, but basically
try
{
mysql_begin_transaction(); //not correct syntax
mysql_query("UPDATE table1..."); // not correct syntax
mysql_query("UPDATE table2..."); // not correct syntax
msyql_commit_transaction() // not correct syntax
}
catch (Exception E)
{
msyql_rollback_transaction(); // not correct syntax
}
Upvotes: 1