May 2003
Intermediate to advanced
592 pages
14h 28m
English
The next logical function to discuss is mysql_num_rows(). This function returns the number of rows retrieved by a SELECT query, taking the query result as a parameter.
I’ll use this function in two different ways. First I’ll modify view_users.php to list the total number of registered users. Second, I’ll modify register.php to test if a username has already been taken.
1. | Open view_users.php (refer to Script 6.7) in your text editor.
|
2. | Before the if ($result) conditional (line 12), add this line (Script 6.9)
$num = mysql_num_rows ($result); |
3. | Change the original $result conditional to if ($num > 0) { The conditional ... |
Read now
Unlock full access