PDA

View Full Version : Problem with counter on shopping cart


mancroft
07-24-2003, 11:37 PM
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?

Spookster
07-25-2003, 12:27 AM
This would be a PHP problem verses a MySQL problem.

You are getting that "Resouce ID" thing because you are referring to the resource ID of the results of the query verses the content of the results of the query(which of courese is just an array). You will want to refer to it in this manner:

$row = mysql_fetch_array($thecounter);
echo $row['count'];