Are you trying to get the auto_increment "id" used in the last Insert ? If
so, try this function:
// int mysql_insert_id(int [link_identifier] );
$last_id = mysql_insert_id($result);
$sql2 = "INSERT INTO pages page_id values($last_id );
$result2 = mysql_query($sql2);

HTH

Jayme.

http://www.conex.com.br/jjeffman



-----Mensagem Original-----
De: Rubanowicz, Lisa <[EMAIL PROTECTED]>
Para: Rubanowicz, Lisa <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Enviada em: terça-feira, 23 de janeiro de 2001 11:54
Assunto: RE: [PHP-DB] Newbie - 2 tables one insert


> I realised I just sent my password out needless to say I am just about to
> change it.
> All the Best
> Lisa
>
> -----Original Message-----
> From: Rubanowicz, Lisa [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 23, 2001 1:54 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Newbie - 2 tables one insert
>
>
> Hi all,
> Could you please help me out on this one.
> I want to create a web site using two tables.
> 1. page_creation - Stores page_id and page_name to be shown on all
> navigation bars.
> 2. pages - Contains pg_id, page_id, etc etc.
> I want to do an insert into page_creation to create a new page and then
pass
> the page_id to pages, so I know the info stored in "pages" relates to a
> certain page (one to many relationship).  In the code below I want this to
> be an "Add a New web Page" where the user types in a Page Name shown in
the
> nav bar and it enters data as above.
> I have been trying for three days now with different methods and it is
> driving me mad.
> Thank you in advance for your assistance
>
>
> <?
> if ($page_name) {
>
> $host="db9.pair.com";
> $user="c3po";
> $password="13Balreask";
> $dbasename="c3po_test";
>
> mysql_pconnect("$host","$user","$password")
> or die("Unable to connect to SQL server");
> mysql_select_db("$dbasename") or die("Unable to select database");
>
> $sql1 = "INSERT INTO page_creation pagename";
> $sql1 = "values('$page_name')";
> $result = mysql_query($sql1);
> $sql2 = "INSERT INTO pages page_id values('$result');
> $result2 = mysql_query($sql2);
> }
> else {
> ?>
> <HTML>
> <HEAD>
> </HEAD>
> <BODY BGCOLOR="#FFFFFF">
> <FORM ACTION="test_2_tables.php" METHOD="POST">
> <INPUT TYPE=TEXT name="page_name" VALUE="<?echo $page_name ?>" SIZE=20>
> <INPUT TYPE=SUBMIT VALUE="Add a New Page">
> </FORM>
> </BODY>
> </HTML>
> <? }
> ?>
>
>
>
>
> Lisa Rubanowicz
> Case ITC,
> Navan, Ireland
> Tel: #353 (0)46 77663
>
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to