I am looking to retreive a numerical value from the database
function adminLevel()
{
$q = "SELECT userlevel FROM ".TBL_USERS." WHERE id = '$_SESSION[id]'";
return mysql_query($q, $this->connection);
}
This is the SQL.
I then wrote the following php/html:
<?php
$q = $database->adminLevel();
if ($q > 7)
{
?>
<a href="newleague.php">Create a new league</a>
<?
}
?>
The problem I have is that the userlevel returned isn’t affecting the if statement. It is always displayed. How do i get it to test the value of userlevel is greater than 7?
Thanks
adminlevel()doesn’t return an integer here. It returns a mysql resultset object containing a single row and a single column; the data point contained within happens to be an integer. Presumably, however PHP compares that object to integers happens to alwayus result in its being larger than 7. But it’s not comparing the integer you wanted to compare. Try this: