cyberspace
Technical User
i'm still in the learning process of php/mysql and i'm trying to add validation etc to pages.
i have this script to show users:
$viewusers = mysql_query("SELECT * FROM users") or
die("Error: Could not select users");
print ("<h2>Current users</h2>");
while ($rec = mysql_fetch_array($viewusers))
{
print ( $rec["username"] . "</p>\n");
}
That works just fine...pretty simple stuff.
What i would also like to do is if the USERS table is empty, have the message "there are no users" instead of showing a blank list.
i tried making an if statement before the initial print statement, eg if users = empty { echo "no records" else etc etc. } but got an error.
What am i doing wrong?
thanks.
'When all else fails.......read the manual'
i have this script to show users:
$viewusers = mysql_query("SELECT * FROM users") or
die("Error: Could not select users");
print ("<h2>Current users</h2>");
while ($rec = mysql_fetch_array($viewusers))
{
print ( $rec["username"] . "</p>\n");
}
That works just fine...pretty simple stuff.
What i would also like to do is if the USERS table is empty, have the message "there are no users" instead of showing a blank list.
i tried making an if statement before the initial print statement, eg if users = empty { echo "no records" else etc etc. } but got an error.
What am i doing wrong?
thanks.
'When all else fails.......read the manual'