...

View Full Version : php and mysql



negar
03-21-2004, 09:20 PM
i have a CustDetails table with attributes
ID
Username
....

and

Products table with attributes
ProdID
Prodname
....

and

cart table with attributes
cartID
ProdID
ID

i was wondering there was any way that when a user selects the add item link that the item is added to the cart table but also the ProdID and the users ID. i need an insert statement that will link the CustDetails.ID to cart.ID and Products.ProdID to cart.ProdID.
can anyone help me?
Thanx

raf
03-22-2004, 08:34 AM
Welcome here!

No. You can only insert in one table at a time through SQL.

If you would use a db that supports stored procedures (like Oracle, MsServer, PostGreSQL,...) then you could set up a triger --> stored procedure that perform an action when fired of by another action. So then you could do the insertion to table 2 an 3 automatically.

This wount save you any coding if you only need this feature on one page (an insert with embedded SQL is just one line of code)

Triggers are specialy usefull if you frequently need this sort of multi table insert/deletes/updates in a higher number of pages. Then you only nee to set it up once and only maintain one piece of code.
Might be worth looking into InnoDB tables for an on delete or on update cascade."



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum