RE: [PHP-DB] Newbie - 2 tables one insert
| From: | Rubanowicz, Lisa | Date: | Tue, 23 Jan 2001 13:54:40 +0000 |
| Subject: | RE: [PHP-DB] Newbie - 2 tables one insert | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-6091@lists.php.net to get a copy of this message | ||
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:lisa.rubanowicz@cnh.com]
Sent: Tuesday, January 23, 2001 1:54 PM
To: php-db@lists.php.net
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
lisa.rubanowicz@cnh.com <mailto:lisa.rubanowicz@cnh.com>