开发者

insert entries in multiple tables in php

I found this tutorial at tizag.com. But It is for displaying entries from different tables. How can I do an insert?

         <?php
    // Make a MySQL Connection
   // Construct our join query
 开发者_StackOverflow     $query = "SELECT family.Position, food.Meal ".
      "FROM family, food ".
"WHERE family.Position = food.Position";

      $result = mysql_query($query) or die(mysql_error());


      // Print out the contents of each row into a table 
     while($row = mysql_fetch_array($result)){
echo $row['Position']. " - ". $row['Meal'];
echo "<br />";
      }
      ?>


You mean inserting data into multiple database tables with one query?
You can't.

Read the MySQL INSERT syntax reference.

Of course you can loop over your data and e.g. insert it into various tables step by step, but without real code from your side it is hard to help.


There are a tutorial on same site: SQL Tutorial - Insert

This can also be useful: PHP MySQL Insert Into

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜