What am i doing wrong here, the output is always 'empty'

<?php
$result = mysql_query("SELECT username FROM users
WHERE seatnum='seat1'") or die(mysql_error());

 if (seatnum == seat1) {
echo username;
} else {
echo 'empty';
}
?>

Just guessing since I'm not sure what you're trying to do, but...

<?php

$result = mysql_query("SELECT username FROM users WHERE seatnum='seat1'")
          or die(mysql_error());
list($username) = mysql_fetch_array($result, MYSQL_NUM);

if ($seatnum == "seat1") {
        echo $username;
}else {
        echo 'empty';
}
?>


What I'm not seeing is where you set $seatnum in the first place and why you're doing the if/else at all since your mysql query will only return a username *if* seatnum='seat1' already so the above code I'm guessing will always print out $username (or blank if the query returns no results).


Anyway, the above should get you going in the right direction...

-philip

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to