newbtophp Posted December 25, 2009 Share Posted December 25, 2009 I've got a problem, i want to echo some images depending on the $id, however for me to get that id i have to extract it from a query. So i've done that, but i want to extract all id's (not just 1), so i can echo images for all them ids (not just echo the images based on 1 id), so I did a while() loop, however doesnt seem to work :-\ My code: <?php include "connect.php"; $user = "Peter"; $sql = mysql_query("select * from game_main where user = '$user'"); while($row = mysql_fetch_array($sql)){ $id = $row['id']; } //do i have to do foreach $id as something?? $views = mysql_num_rows(mysql_query("SELECT userip FROM game_views WHERE sub_id = '$id'")); $sql3 = mysql_query("select monthstamp from game_monthlyfeatured where first = '$id'"); $num3 = mysql_num_rows($sql3); $sql4 = mysql_query("select weekstamp from game_weeklyfeatured where first = '$id'"); $num4 = mysql_num_rows($sql4); $sql5 = mysql_query("select daystamp from game_dailyfeatured where first = '$id'"); $num5 = mysql_num_rows($sql5); $sql6 = mysql_query("select date from site_featured where id = '$id'"); $num6 = mysql_num_rows($sql6); if($num3 == 1) { ?> <img src="../images2/game/game_awards_1monthly.gif" width="20" height="20" /> <?php } if($num4 == 1) { ?> <img src="../images2/game/game_awards_topweekly.gif" width="20" height="20" /> <?php } if($num5 == 1) { ?> <img src="../images2/game/game_awards_topdaily.gif" width="20" height="20" /> <?php } if ($views > 1000) { ?> <img src="../images2/game/game_awards_1000views.gif" width="20" height="20" /> <?php } if ($views > 25000) { ?> <img src="../images2/game/game_awards_25000views.gif" width="20" height="20" /> <?php } if ($num6 > 0) { ?> <img src="../images2/game/game_awards_modpick.png" width="16" height="16" /> <?php } ?> Hope someone can help, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/186300-help-with-variable/ 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.