PDA

View Full Version : count rows and then use them



Dennis_Gull
05-01-2007, 03:11 PM
Hello, I just got a fast question. If I wanna check how many rows I selected I got to use "select COUNT(*) as numbers_of_rows" but I cant use the info inside the COUNT then so do I have to use select twice (one for count and once without count) or is there another way to do this?

mburt
05-01-2007, 03:18 PM
Use:

$query = "SELECT * FROM mydatabase";
$number = mysql_num_rows(mysql_query($query));
$number will have the number of rows starting at 1. You will often havet o subtract 1 when encorperating into query strings, seeings that index starts at 0.

Dennis_Gull
05-01-2007, 07:10 PM
Thank you, that helped a lot.