onthespot Posted July 12, 2009 Share Posted July 12, 2009 Can anyone understand this problem? I am calling from a table in my database which works fine when I don't include a WHERE. However when I do, i get nothing back. The php: <?php function show_league_image($type) { $images = array ( 'league1' => 'first.jpg', 'league2' => 'second.jpg', 'league3' => 'third.jpg' ); if(array_key_exists($type, $images)) return '<img src="images/awards/'.$images[$type].'" width="16" height="36" />'; return false; } $res=mysql_query("SELECT * FROM ".TBL_AWARDS." WHERE awarduser = '$awarduser2' ORDER BY awarddate"); while($row=mysql_fetch_assoc($res)){ $type=$row['awardtype']; $awarduser=$row['awarduser']; $awarduser2 = $_GET['user']; echo show_league_image($type) } ?> This just won't work, however when I remove the WHERE, it will? Quote Link to comment Share on other sites More sharing options...
onthespot Posted July 12, 2009 Author Share Posted July 12, 2009 anyone? Quote Link to comment Share on other sites More sharing options...
Prismatic Posted July 12, 2009 Share Posted July 12, 2009 Can anyone understand this problem? I am calling from a table in my database which works fine when I don't include a WHERE. However when I do, i get nothing back. The php: <?php function show_league_image($type) { $images = array ( 'league1' => 'first.jpg', 'league2' => 'second.jpg', 'league3' => 'third.jpg' ); if(array_key_exists($type, $images)) return '<img src="images/awards/'.$images[$type].'" width="16" height="36" />'; return false; } $res=mysql_query("SELECT * FROM ".TBL_AWARDS." WHERE awarduser = '$awarduser2' ORDER BY awarddate"); while($row=mysql_fetch_assoc($res)){ $type=$row['awardtype']; $awarduser=$row['awarduser']; $awarduser2 = $_GET['user']; echo show_league_image($type) } ?> This just won't work, however when I remove the WHERE, it will? You specify $awarduser2 AFTER the query, so $awarduser2 is always blank in the query. $awarduser2 = mysql_real_escape_string($_GET['user']); $res=mysql_query("SELECT * FROM ".TBL_AWARDS." WHERE awarduser = '$awarduser2' ORDER BY awarddate"); And remove $awarduser2 = $_GET['user']; from your while loop. Edit - Also, don't bump your thread after only 20 minutes. Your thread will be gotten to eventually. Quote Link to comment Share on other sites More sharing options...
onthespot Posted July 12, 2009 Author Share Posted July 12, 2009 thanks a lot, that worked, lesson learnt, cheers Quote Link to comment 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.