SitePoint Sponsor

User Tag List

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

    Problem with counter on shopping cart

    Hello
    I am making a shopping cart and need a simple counter to add as an order number.
    The cart table in phpmyadmin looks like:
    zzzzzzzzzzzzzzzzzzz
    Database my_cart - table simplecount running on localhost
    SQL-query

    SQL-query : [Edit]
    SELECT * FROM `simplecount` LIMIT 0, 30
    count count_id
    24 1
    zzzzzzzzzzzzzzzzz
    so I know the counter is working.
    However the code on the emailform where the counter information is transmitted looks like this:
    zzzzzzzzzzzzzzzzzz
    mysql_query("UPDATE simplecount SET count = (count + 1) WHERE count_id = 1",$con);
    $thecounter = mysql_query( "SELECT count FROM simplecount WHERE count_id = 1;",$con);
    zzzzzzzzzzzzzzzzzzzzzzzzzz
    and produces the output:
    ORDER NUMBER: Resource id #3
    instead of
    ORDER NUMBER: 24
    which I would expect.
    Any ideas please?
    :

    :

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Location
    Toronto, ON
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are just querying the database with that. You still need to get the output from the returned rows:
    PHP Code:
    $count mysql_result($thecounter,0,0
    $count should now hold the number, 24.

    Matt

  3. #3
    Old Fogey mancroft's Avatar
    Join Date
    Oct 2002
    Location
    lost
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Matt. Easy when you know how!
    :

    :


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
  •