SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Old Fogey mancroft's Avatar
    Join Date
    Oct 2002
    Location
    lost
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    join tables and send email

    First, to say that I really appreciate all the help from this forum!
    Still on the shopping cart problem... the mysql database has two tables: cart and items please see details below.
    What I am trying to do is create a mailform to send out details of the customer selections to the "shop".
    So far the following is working:
    $result = mysql_query("SELECT * FROM cart",$con);
    if ($result === false) die("failed");
    while ($row=mysql_fetch_row($result)) {
    $content .= "Ref no:" .$row[2]."\nqty: ".$row[3]."\n\n";}
    This sends the ref no and quantity from the table cart.
    What I wish to do AS WELL is to send itemName and itemPrice from the table items.
    Any ideas please?
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    table items:
    Field Type Attributes Null Default Extra Action
    itemId int(11) No auto_increment Change Drop Primary Index Unique Fulltext
    itemName varchar(50) Yes NULL Change Drop Primary Index Unique Fulltext
    itemDesc varchar(250) Yes NULL Change Drop Primary Index Unique Fulltext
    itemPrice decimal(4,2) Yes NULL Change Drop Primary Index Unique Fulltext

    >>>>>>>>>>>>>>>>>>>>
    >>>>>>>>>>>>>>>>>>>>
    table cart:
    Field Type Attributes Null Default Extra Action
    cartId int(11) No auto_increment Change Drop Primary Index Unique Fulltext
    cookieId varchar(50) Yes NULL Change Drop Primary Index Unique Fulltext
    itemId int(11) Yes NULL Change Drop Primary Index Unique Fulltext
    qty int(11) Yes NULL Change Drop Primary Index Unique Fulltext

    >>>>>>>>>>>>>>>>>>>>
    :

    :

  2. #2
    SitePoint Zealot
    Join Date
    May 2003
    Location
    Dover, PA
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to use a join:

    Code:
    SELECT cart.carId, cart.cookieId, cart.itemId, cart.qty, items.itemName, items.itemPrice FROM cart, items WHERE cart.itemId = items.itemId
    http://www.statgfx.com


Bookmarks

Posting Permissions

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