jmholl5 Posted May 16, 2009 Share Posted May 16, 2009 So I pretty new to PHP and MySQL, but I've been doing pretty well at getting what I want done for this website I volunteered to make, but now I've come to something that I don't know how to approach, and I think recursion is the answer. Here is my table structure: | id | class | playername |award | The thing is there are some players with 1 award and some with 5. So the player with 5 awards has 5 separate entries in the table, one for each award. This is all fine, but I'd like to display the data in this way: <h3>class</h3> <h4>1st playername for above class</h4> <ul> <li>1st award for above playername</li> <li>2nd award for above playername(if it exists)</li> (continue to list all awards in own list item until complete) </ul> <h4>2nd playername for above class</h4> <ul> <li>1st award for above playername</li> <li>2nd award for above playername(if it exists)</li> (continue to list all awards in own list item until complete) </ul> Then repeat for all the data in the table. Basically I only want to display each class once, then all the playernames for that class, and then all the awards for each playername under each one. Just looking for advice on whether or not this is possible and if so how to do it. I'm also open to changing my table structure if that would make it easier. I tried looking through PHP recursion tutorials but couldn't figure it out. Thanks Link to comment https://forums.phpfreaks.com/topic/158414-php-recursion-i-think/ Share on other sites More sharing options...
Ken2k7 Posted May 16, 2009 Share Posted May 16, 2009 I don't really understand, but I doubt you need recursion for this. Link to comment https://forums.phpfreaks.com/topic/158414-php-recursion-i-think/#findComment-835444 Share on other sites More sharing options...
jmholl5 Posted May 16, 2009 Author Share Posted May 16, 2009 It's kind of hard to explain, I'm going to study some more php and hopefully come back with a better explanation of what I need to do. Its pretty much like a nested list or file tree, so I just figured recursion was the answer, but I'm probably wrong. Link to comment https://forums.phpfreaks.com/topic/158414-php-recursion-i-think/#findComment-835448 Share on other sites More sharing options...
Mchl Posted May 16, 2009 Share Posted May 16, 2009 It's not the recursion that you need, but table normalisation. Read this excellent article http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html Link to comment https://forums.phpfreaks.com/topic/158414-php-recursion-i-think/#findComment-835451 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.