I have a table with a series of codes, which has a field called “numerousuarios” which has a default value “0”
Here the code:
$statement = " SELECT numerousuarios FROM codigos WHERE codigos = :codigo";
$sth = $db ->prepare($statement);
$sth -> execute(array(':codigo'=>$codigo));
$result = $sth->fetch();
$mivariable = $result[numerousuarios];
if(!empty($mivariable)){
if($mivariable>=5){
echo "the code is full users";
}
else{
// Do something...
}
}
else{
echo "el codigo no existe";
}
The if (empty ($ myvar)) is to see if that record in the database.
The problem is that if the value is “0” I take it as an empty field.
What am I doing wrong?
You say the result is “0” by default .just check the returend value is not equal 0 🙂
🙂