In the query below, I'm selecting all records in a table, in the future, I may be only selecting a few record from th table.
Is there a way to get the count of records returned by the query, so that I can base what I do next on that count?
Thanks!
$query ="select * from usersTable";
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
} else {
while ($newArray = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $newArray['id'];
$username = $newArray['username'];
$password = $newArray['password'];
echo "ID is ".$id.
"<br/>Username: ".$username.
"<br/>Password:   ".$password.
"<br/>--------------------------------------------<br/>";
}
}
}
PETERV
Syracuse, NY &
Boston, MA
Is there a way to get the count of records returned by the query, so that I can base what I do next on that count?
Thanks!
$query ="select * from usersTable";
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
} else {
while ($newArray = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $newArray['id'];
$username = $newArray['username'];
$password = $newArray['password'];
echo "ID is ".$id.
"<br/>Username: ".$username.
"<br/>Password:   ".$password.
"<br/>--------------------------------------------<br/>";
}
}
}
PETERV
Syracuse, NY &
Boston, MA