tags:

views:

33

answers:

2

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'")
+1  A: 

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
}
Byron Whitlock
A: 

check out Execute Multiple MySQL Queries from One String in PHP.

Otherwise, write separate query statements in your PHP.

carillonator