Query with "if" mode
Posted: Tue Nov 11, 2008 2:58 am
Hello,
I'm writing a page that queries the database to see if a field is built or not.
The problem is that it does not work.
Someone tells me what's wrong?
Thank you very much!
I'm writing a page that queries the database to see if a field is built or not.
The problem is that it does not work.
Someone tells me what's wrong?
Thank you very much!
Code: Select all
$sql2 = "SELECT modelloacquisto1 as modelloacquisto1
IF(modelloacquisto1="",1,0) as modelloacquisto1
FROM utenti";
$result2 = mysql_query($sql2);
if (!$result2) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result2) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
if ($row2['modelloacquisto1'] == 0) {
echo 'ti va di comprare un paio di scarpe?';
else
echo 'Complimenti per il tuo primo acquisto';
}