Jump to content

[SOLVED] Can't figure this one out


Arbitus

Recommended Posts

So I'm creating a cheat code website.

 

I have a table for each system

 

x360

ps3

wii

 

I want to be able to insert rows into each one that has individual cheats in per game. So say Halo has 10 codes, there would be 10 seperate rows for halo.

 

Well this is all fine and dandy untill I try to make a page that displays the games. like so:

<?php
while($rows = mysql_fetch_array($query))
{
?>
<center>
<br>
<a href="/game.php?system=<?php echo $system; ?>&game=<?php echo $rows['game_name']; ?>&id=<?php echo $rows['ID']; ?>"><?php echo $rows['game_name']; ?></a>
</center>
<?php
}
?>

 

When I do this, it displays each one seperatly so since i have 10 halo codes, it shows halo 10 times.

 

So I guess what I'm trying to ask is if I can limit halo to be shown only one time on that page.

 

 

Link to comment
Share on other sites

Well the problem is that if I limit to 1, it will not show all of the games. On this page it will have something like this:

 

Call of duty 4

Call of duty WOW

Halo

 

But right now it looks like this:

 

Call of duty 4

Call of duty 4

Call of duty 4

Call of duty 4

Call of duty WOW

Call of duty WOW

Halo

Halo

Halo

Halo

Halo

 

Since there are rows for each cheat.

Link to comment
Share on other sites

There's probably a much easier way to do this but my head hurts from work:

 

$halo_count = 0;
while($rows = mysql_fetch_array($query))
{
if($rows['game_name'] == 'halo') {
   $count++;
}
if($count > 1 && $rows['game_name'] == 'halo') {
   break;
} else {
?>



   

   }
}
?>

Link to comment
Share on other sites

There's probably a much easier way to do this but my head hurts from work:

 

<?php
$halo_count = 0;
while($rows = mysql_fetch_array($query))
{
if($rows['game_name'] == 'halo') {
   $count++;
}
if($count > 1 && $rows['game_name'] == 'halo') {
   break;
} else {
?>
<center>
<br>
   <a href="/game.php?system=<?php echo $system; ?>&game=<?php echo $rows['game_name']; ?>&id=<?php echo $rows['ID']; ?>"><?php echo $rows['game_name']; ?></a>
</center>
<?php
   }
}
?>

 

The only problem with this is that there will be more than just halo.

 

If you look here: http://arbituz.com/cheat.php?system=x360 You will see what I'm saying.

 

I would prefer to have each code to have it's own row to make user submissions to be easier. But everytime I add a new code, it shows the game name multiple times on the game list page.

Link to comment
Share on other sites

Ok, so I guess I found a solution.

 

I added a new field called 'new' the the rows. if a code for a game that has never been entered is submited. it gets a 1 in new. other than that it has a 0. Then I made it so on the game list it only selects games with a 1 in new.

 

Thanks for all your help. This is probably a hillbilly solution but if you can think of better either send me an email admin@arbituz.com or leave me a message here.

 

Thanks agian!

Link to comment
Share on other sites

Ok, so I guess I found a solution.

 

I added a new field called 'new' the the rows. if a code for a game that has never been entered is submited. it gets a 1 in new. other than that it has a 0. Then I made it so on the game list it only selects games with a 1 in new.

 

Thanks for all your help. This is probably a hillbilly solution but if you can think of better either send me an email admin@arbituz.com or leave me a message here.

 

Thanks agian!

 

I think you're fine with that solution, the 0 and 1 "boolean" method is a common practice.  Although I'm still confused as to what exactly you're trying to accomplish, so I cannot confirm this is a permanent solution.  Sorry  :-\

Link to comment
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.