Name
mysql_num_rows
Synopsis
int mysql_num_rows(qresource query
)
Returns
the number of rows associated with a query
resource handle. The query
resource handle
is returned from a prior call to mysql_query( )
.
The function does not work with
mysql_unbuffered_query( )
. In addition,
this function works only for SELECT
queries; the
number of rows affected by an SQL INSERT
,
UPDATE
, or DELETE
statement
should be determined using the function mysql_affected_rows(
)
.
Example
<?php $query = "SELECT * FROM presents WHERE present LIKE 'M%'"; $connection = mysql_connect("localhost", "fred", "shhh"); mysql_select_db("wedding", $connection); $result = mysql_query($query, $connection); echo "There are " . mysql_num_rows($result) . " presents that begin with M"; ?>
Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.