Spectre Posted July 12, 2009 Share Posted July 12, 2009 I'm working on a little project, just a one page thing, for showing awards earned by a player. Now I have a table, with set size, with a background image of shelving I made for each award to sit on (as an image with a variable of the title of the image). Now the thing is, there can be 16 trophies/awards on one set of shelving, and I'm planning on a paged thing so to start there will be at least 3 pages, so 48 trophies/awards, 16 on page 1, another 16 on page 2 (from id 17 onwards) and same again on page 3. I have it set up as two tables in the db, one holding the 48 rows of achievements (id, image, name, alt_text), and a player table of that showing id, userid, achievement id (a_id). Basically so a player can unlock them as they go and change the image from the silhouette image of a trophy I made, to the actual image with title involving the name and a player stat. Now to my problem, well not so much problem as my brain just saying "I'm not gonna think too well on this". I need to be able to echo out the rows correctly. So that row 1 with it's TD's will echo out on page 1, IDs 1-4 of the awards, row 2 would do the same but echoing 5-8 and so on. But last time I tried something akin to this with a foreach and while it just did it like row 1 was only showing id 1, 4 times, row 2 did id 2 4 times etc... So I ask for any help in creating the function or while/foreach loops correctly so it does as I want with the page numbers working as the limiter to start the id numbers, and it echos out each item correctly. Quote Link to comment https://forums.phpfreaks.com/topic/165720-solved-table-solution/ Share on other sites More sharing options...
wildteen88 Posted July 12, 2009 Share Posted July 12, 2009 Look into pagination to achieve this. Quote Link to comment https://forums.phpfreaks.com/topic/165720-solved-table-solution/#findComment-874205 Share on other sites More sharing options...
Spectre Posted July 15, 2009 Author Share Posted July 15, 2009 I know how to make it change pages, my problem is making it echo the table out correctly. <TABLE WIDTH="400" HEIGHT="450" ALIGN="center" STYLE="background-image: url('image/hutBK.png');"> <tr><td width="15"> </td><td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="15"> </td> </tr> <tr><td width="15"> </td><td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="15"> </td> </tr> <tr><td width="15"> </td><td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="15"> </td> </tr> <tr><td width="15"> </td><td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="10"> <td><img src="image/achievement_locked.png" title="Locked Achievement!"></td><td width="15"> </td> </tr> <tr height="30"></tr> </table> Ok so that there is what the table will need to be set up like (it's my test table I was doing with obviously manual cell entries to get my spacing sorted) That's what it looks like. Now what I want is, to select all the rows from the achievements table, and echo out as per the above, each will appear like above until the achievement is unlocked, and at that point, by using a check against pachievements table it'd echo the actual image path from the achievements table instead of the locked image, and well will do that for all the cells (check to see if player has the achievement and echo the cell with the right image, else echo the cell from above example showing the locked achievement. I just can't wrap my head around it (considering some of the things I have achieved, this is just annoying as I know it should be simple but my mind keeps going blank) Quote Link to comment https://forums.phpfreaks.com/topic/165720-solved-table-solution/#findComment-875669 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.