I am trying to find a solution to enter data from a web page to several
tables in the same database; actually,  I have 9 tables bus several are
basically id fields for foreign keys.
So far, I have found:
"use mysql_insert_id()" - the examples and directions are
incomprehensible (to me, anyway)
"use several insert statements" - what do you mean by that?

The following is what I am trying to use - the first INSERT INTO books
works fine.  The rest, no.
The string $some_fieldIN are values from input statements.

$sql1 = "INSERT INTO books ( title, sub_title, descr, comment, bk_cover, 
publish_date, ISBN, language ) VALUES ('$titleIN', '$sub_titleIN', 
'$descrIN','$commentIN', '$bk_coverIN', '$publish_dateIN', '$ISBNIN', 
'$languageIN')";

$result1 = mysql_query($sql1, $db);
                
$sql1 = "INSERT INTO authors (first_name, last_name) VALUES ('$first_nameIN', 
'$last_nameIN')";
                
$result = mysql_query($sql1, $db);
                
$sql1 = "INSERT INTO publishers (publisher) VALUES ('$publisherIN')";   

$result = mysql_query($sql1, $db);

Obviously, I don't understand anything here.
Questions:
1.  Do we really need the statements - $result1 = mysql_query($sql1,
$db); ? Why? What purpose do they serve?

2. How can one use "mysql_insert_id()" to insert data into multiple
tables? Why would you need to insert an id - especially since there are
only 2 fields in the pulblishers table (above) - id (auto-increment) and
publishers? As I ;understand it, when the id field is auto-increment, a
simple

INSERT INTO publishers  (publisher) VALUES ('$publisherIN') works fine (but not 
above)

Can somebody suggest anything? TIA


-- 

Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to