There are two tables related.

Here is a sample

SELECT * FROM access INNER JOIN pages ON = 

And how to make UPDATE simultaneously in two tables. Something like

 UPDATE access INNER JOIN pages ON = SET ..... 

There are such UPDATE you

 mysql_query("UPDATE pages SET name='".$name."', title='".$title."', active='".$active."', keywords='".$keywords."', description='".$description."', position='".$position."' WHERE id='".$id."' "); mysql_query("UPDATE access SET admin='".$access_admin."', moderator='".$access_moderator."', user='".$access_user."', guest='".$access_guest."' "); 

How is it possible to connect them?

In the first update, you can edit the data related to a particular page.

In the second update, you can edit the data in all columns of the table.

It turns out that when you edit a page, the second update edits the data of all pages.

Please help not by word but by deed. If anyone knows the answer, give it a try.

  • four
    And what does not work? Take this sample just correctly write update - Gorets
  • four
    @kostya, you are not welcome here . Goodbye. - Oleg Arkhipov
  • four
    @kostya, you would be watching the language, sir! At school, so you will communicate. - Deonis

2 answers 2

Anything is possible, friend

 mysql_query("UPDATE pages p, access a SET'".$name."', p.title='".$title."','".$active."', p.keywords='".$keywords."', p.description='".$description."', p.position='".$position."', a.admin='".$access_admin."', a.moderator='".$access_moderator."', a.user='".$access_user."', a.guest='".$access_guest."' WHERE = AND id='".$id."' "); 

    No, you create a transaction, you update the data. If both are successful, you save, if not, you roll back:

     try{ $pdo -> beginTransaction(); // ... update query $pdo -> commit(); } catch { $pdo -> rollBack(); } 
    • Well, here are some examples of functions: function mysql_tranc_begin () {@mysql_query ("BEGIN"); } function mysql_tranc_commit () {@mysql_query ("COMMIT"); } function mysql_tranc_rollback () {@mqql_query ("ROLLBACK"); } - Anton Vladimirov