Hey there
Bit of a weird subject there, but hope it attracted the right type of people for the answer im looking for 🙂
Ive got a db table holding information on a series of games that have been played. which includes the field id. Each row represents one game, and holds the information for that game.
The problem can be seen from this page here:
http://www.shankypants.co.uk/shithead/plyrview.php?plyr=Neilk0505&gameid=202&typegame=true
which shows a list of the players (neilk0505) games. The problem arises when I want to add a 'prev' and 'next' game links next to the current game, to show that players next game and previous game (according to the list below, ie, in the example page above the next game would be 203, and the previous game would be 184).
At the moment my code for showing the list of all that players games runs something along the lines of ...
for(0 to end of table for all the games)
{
get next row (1 single games details)
check if selected player was in that game
if he was
{
show link code
show other game code
}
}
I cant do a better db query than selecting all games as i didnt design the db too well at first and the players in the game are held in one big string in one field in the db (but anyway, that doesnt matter atm).
Now the problem comes when I try adding a prev and next game links to the top game. The way I was going to do this is to just add a couple more variables into the 'show link code' (ie nextgame=$blabla&prevgame=$blabla2). At the moment I can grab the next game id, as I can just store it as a variable from the php iteration before, but getting the previous game id would involve me looking at the next row that the player is in (in the if he was found statement), and finding the id, but then Ive grabbed that row from the db, so next time I call mysql_fetch_row it will be the row after that (ie it will show every other game)....... (I know this is a bit backwards, but they are ordered DESC, so previous game really means the next game got from the db).
Can anyone see a solution to this, or what avenue should I head down? Full code for displaying a 1 game in the list (not the top featured game) is shown below:
Thanks for any help, and any more info needed just ask
Ta
Nick
for($i=0; $i < mysql_num_rows($result_allsess); $i++)
{
$row_allsess = mysql_fetch_row($result_allsess);
$found = (strpos($row_allsess[1],$plyr) === false ? 0 : 1);
if($found)
{
$sess_id = $row_allsess[0];
echo("<TR bgcolor=\"#DDDDDD\">");
echo("<TD><a href=\"plyrview.php?plyr=$plyr&gameid=$sess_id&typegame\">" . $row_allsess[0] . "</a></TD>");
//change to?
//echo("<TD><a href=\"plyrview.php?plyr=$plyr&gameid=$sess_id&typegame=&nextgame$nextid=&prevgame=$previd\">" . $row_allsess[0] . "</a></TD>");
echo("<TD>" . $row_allsess[3] . "</TD>");
echo("<TD>" . $row_allsess[4] . "</TD>");
echo("<TD>" . $row_allsess[5] . "</TD>");
echo("</TR>");
$nextid = $sess_id;
$previd = ?? }
}