|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Inserting Data into two tables
I've got this products page form and what I have is two tables to insert the data into, about_products,about_urls.
What I am trying to achieve is to insert info into about_products table and the URLs associated for that product. The thing is, is that I'm having trouble getting to insert the URLs for that product. Database Structure: PHP Code:
As you can see I've used pid as a foreign key to about_products. code: PHP Code:
So what I am trying to achieve here is to insert the product details into the database, get the last id then insert into about_urls table, the urls associated for that product. (which they can be upto 3 urls for that product). at the moment its doing this.... http://www.manutd.com/ http://www.mancity.com/ (Product 1) http://www.df.com/ http://www.msdf.com/ (Product 2) insert into about_products (title,intro,price,prodinfo) values ('sd','sd','sd','d') insert into about_urls (url,pid) values ('http://www.manutd.com/',91) insert into about_products (title,intro,price,prodinfo) values ('ghj','h','gj','') insert into about_urls (url,pid) values ('http://www.mancity.com/',92) So really it should insert the first product into database with the two urls, then next product and the two urls for that... I'm going astray here but don't know how to overcome this sticky problem. Any help much appreciated... Ozzie |
|
#2
|
|||
|
|||
|
Have you tried using mysql_insert_id() ?
|
|
#3
|
|||
|
|||
|
No, I haven't, in what context do you mean??
Thanks Ozzie |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Inserting Data into two tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|