Jump to content

Recommended Posts

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.  ???

Link to comment
https://forums.phpfreaks.com/topic/74183-why-isnt-this-working/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/74183-why-isnt-this-working/#findComment-374641
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/74183-why-isnt-this-working/#findComment-374646
Share on other sites

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 ;)

Link to comment
https://forums.phpfreaks.com/topic/74183-why-isnt-this-working/#findComment-374649
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.