-
Step 1
This tutorial assumes that you know how to connect to a MySQL database using PHP. If not, please see my other tutorials on this issue. I have very easy to follow step by step instructions to get you up to speed.
-
Step 2
First we setup our query that we need to excute. That is done with:
"$RESULT=mysql_query("SELECT * FROM SOME_TABLE");"
This line of code says run the select query and assign the results to the variable "$RESULT". -
Step 3
We obtain the number of rows returned in that query by using the built in function "mysql_num_rows". That is written like this:
$NUMBER_OF_ROWS = mysql_num_rows($RESULT);
This says assign the number of rows returned from the result variable we created in step 2 in the variable "$NUMBER_OF_ROWS".
Now we can use this variable to test for conditions in switch statements, if-else statements, loops and so on.








