I have a query that selects records from a DB and then loops through the records and checks certain Values, I am looking to see how I can produce a No Records error if the are no records when the query is run.
Here is my code:
$sql = "SELECT * from users where username like '$portaluser'
";
#execute the query
$result = mysql_query($sql)
or die("Error!");
while ($row = mysql_fetch_array($result)) {
$dbsession = $row['currentsession'];
$portallevel = $row['level'];
if ($dbsession == $PHPSESSID){
$message = "All okay";
} else {
header("Location: http://LOCATION GOES HERE");
}
}
It seems quite simple but I have been looking for the answer, many thanks inadvance