tags:

views:

38

answers:

2

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
      $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 />";
      }
      ?>
A: 

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

This can also be useful: PHP MySQL Insert Into

Rubens Farias
+1  A: 

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.

Felix Kling
thanks, I never thought that the usual insert statement would do. It's just adding 2 sql queries for inserting in 2 tables.