O'Reilly logo

Sams Teach Yourself PHP in 24 Hours, Third Edition by Matt Zandstra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing Information

Now that we can add information to a database, we need to look at strategies for retrieving the information it contains. As you might guess, you can use mysql_query() to make a SELECT query. How do you use this to look at the returned rows, though? When you perform a successful SELECT query, mysql_query() returns a result resource. You can pass this resource to other functions to access and gain information about a resultset.

Finding the Number of Rows Found by a Query

You can find the number of rows returned as a result of a SELECT query using the mysql_num_rows() function. mysql_num_rows() requires a result resource and returns a count of the rows in the set. Listing 13.4 uses a SQL SELECT statement to request all rows ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required