Warptweet Posted October 21, 2007 Share Posted October 21, 2007 I've used this kind of code for different scenarios a million times. Theres almost no reason why this shouldn't work... $id = $_GET['id']; if ($id = 1){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' ORDER BY game_id DESC LIMIT 18"); echo "<center><h2>Most Recent 18</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 2){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Action' ORDER BY game_id DESC"); echo "<center><h2>Action Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 3){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Sports' ORDER BY game_id DESC"); echo "<center><h2>Sports Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 4){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Puzzle' ORDER BY game_id DESC"); echo "<center><h2>Puzzle Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 5){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Strategy' ORDER BY game_id DESC"); echo "<center><h2>Strategy Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 6){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Adventure' ORDER BY game_id DESC"); echo "<center><h2>Adventure Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 7){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Arcade' ORDER BY game_id DESC"); echo "<center><h2>Arcade Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = { $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Shooting' ORDER BY game_id DESC"); echo "<center><h2>Shooting Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 9){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_categorytwo='Other' ORDER BY game_id DESC"); echo "<center><h2>Other Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } www.warptweet.com You can view the game portal. Try clicking some categories, try clicking the "Action" category or the "Puzzle" category, anything you feel like. Yet strangely, according to $id=$_GET['id'] - EVERY category displays the most recent 18 games! Why is this? This code returns no errors as you can see on my website. What seems to be the problem? All help is appreciated. ??? Quote Link to comment https://forums.phpfreaks.com/topic/74183-why-isnt-this-working/ Share on other sites More sharing options...
bozebo Posted October 21, 2007 Share Posted October 21, 2007 Well.. we can start off by highlighting it: $id = $_GET['id']; if ($id = 1){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' ORDER BY game_id DESC LIMIT 18"); echo "<center><h2>Most Recent 18</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 2){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Action' ORDER BY game_id DESC"); echo "<center><h2>Action Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 3){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Sports' ORDER BY game_id DESC"); echo "<center><h2>Sports Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 4){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Puzzle' ORDER BY game_id DESC"); echo "<center><h2>Puzzle Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } Ok I have cut out the latter repetitions of that big if statement because It is likely that your problem is repeated. I think there is a problem in your mysql query because the php seems correct. Try swapping the queries for this: $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Sports' ORDER BY game_id DESC") or die(mysql_error()); That way it will tell you what is wrong with the query. Quote Link to comment https://forums.phpfreaks.com/topic/74183-why-isnt-this-working/#findComment-374641 Share on other sites More sharing options...
MasterACE14 Posted October 21, 2007 Share Posted October 21, 2007 please keep in mind for the future, to create a thread with a more 'helpful' subject, "Why isn't this working?" puts people off completely , a short and simple and self explaining subject will get you help quicker Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/74183-why-isnt-this-working/#findComment-374646 Share on other sites More sharing options...
JJohnsenDK Posted October 21, 2007 Share Posted October 21, 2007 in all your if statements you have to change this: if ($id = 1){ to: if($id == 1){ you need to use 2 equals tags instead of one. Anohter thing is that you use make your code more dynamic... make a function to handle your script... makes it way faster Quote Link to comment https://forums.phpfreaks.com/topic/74183-why-isnt-this-working/#findComment-374649 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.