Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: php and mysql

  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php and mysql

    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

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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."
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •