wwfc_barmy_army Posted June 14, 2008 Share Posted June 14, 2008 Hello everyone, i have this code: $result = mysql_query("SELECT * FROM user WHERE user_id = $user_id") or die(mysql_error()); while ($qry = mysql_fetch_array($result)) { while ($i <= $rowcount){ $result3 = mysql_query("SELECT * FROM type WHERE type_id = $i") or die(mysql_error()); $qry3 = mysql_fetch_array($result3); $isvalue = $qry[$i]; echo $isvalue; if (isset($isvalue) || $isvalue != "" || $isvalue != " "){ echo "<img src='images/" . $qry3['imgurl'] . "'/> " . $qry[$i] . "<br/>"; } else { echo "nothing"; } $i = $i + 1; } } When run it echos the "<img... etc", although for some reason if there isn't a value for one record in the database it will still print it, any ideas? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/110210-solved-code-problem/ Share on other sites More sharing options...
TEENFRONT Posted June 14, 2008 Share Posted June 14, 2008 i believe its to do with the line.. if (isset($isvalue) || $isvalue != "" || $isvalue != " "){ im sure theres another way to use the || command.... im on my pda right now though so hopefully someone else can help. Quote Link to comment https://forums.phpfreaks.com/topic/110210-solved-code-problem/#findComment-565541 Share on other sites More sharing options...
hansford Posted June 14, 2008 Share Posted June 14, 2008 use && instead of || but if your DB returns a null value then you'll have to check for that as well. Quote Link to comment https://forums.phpfreaks.com/topic/110210-solved-code-problem/#findComment-565557 Share on other sites More sharing options...
wwfc_barmy_army Posted June 14, 2008 Author Share Posted June 14, 2008 Ahh the && worked! Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/110210-solved-code-problem/#findComment-565577 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.