Log in

View Full Version : Query troubles \ question ..


Guy G
12-30-2004, 09:51 PM
i wanna count how many X items a user have.
so i set up this query:

SELECT *
FROM vb3_table
WHERE userid = 1

and it gives all the items a the user have according to his userid..

now i want to count it... so how do i add to the query or count the number of item'sID with in the array which is formed?
i want it to have lika a varable, $total = (number of items found according to item's id).

hope i got it clear enough... :P

Guy G
12-30-2004, 09:59 PM
ok will this work?

mysql_num_rows( $result );

ok it will probably work... but, how can i create a multi-dimensional array from the result?

say it will return 3 rows, each row and its id number, so it will be like that:

$array[0][title](and so forth...)
$array[1][title](and so forth...)
$array[2][title](and so forth...)


is that even possible?

Dean C
12-30-2004, 11:33 PM
You can't turn a multidimensional array via MySQL. To answer your original question you'll need to use MySQL's COUNT() function like so:


SELECT COUNT(*) as total FROM user WHERE userid = 1

Guy G
12-31-2004, 07:43 AM
aight thanks