-3
Good morning, everyone!
I am starting and with a basic doubt... I need to perform an if with a database information. I connect and select it, then I need the variable to use in if.
$idusuario = $_SESSION['idusuario'];
$categorias = "SELECT * FROM categorias WHERE idusuario = '$idusuario'";
$resultado = mysqli_query($con, $categorias);
Here, I need to compare the value of the "confirmed" column of the database to the user who is logged in, something like:
if $confirmado == 0
{
echo "XXXXX";
}
Can you help me with that question?
Thank you!
here on the site is full of examples such as: https://answall.com/q/209975/57220 and https://answall.com/q/133463/57220
– Ricardo Pontual
These examples are using while, examples like this really have a lot. But this is the only way? Because I thought there was a simpler one!
– Felipe Bergamini
Just exchange the while for if. The difference is that while goes through all the lines and if it will only get the first one (if the query only returns one line, it will not make a difference)
– hkotsubo
a select always returns a list of results, you need to fetch, even if only to get the first result
– Ricardo Pontual