spinsfil Posted December 14, 2010 Share Posted December 14, 2010 hi i have a db of tv shows, episodes and descriptions. they are in the db like: name | series | episode | description Friends | 1 | 1 | example Friends | 1 | 2 | example Scrubs | 1 | 1 | example I want to display it this way: Friends Series 1 Episode 1 Series 1 Episode 2 Scrubs Series 1 Episode 1 cant seem to get it to fully work - it will display it for the first show but not do more than one thanks for any help Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 14, 2010 Share Posted December 14, 2010 Please post your code. Ken Quote Link to comment Share on other sites More sharing options...
spinsfil Posted December 14, 2010 Author Share Posted December 14, 2010 $getshows = mysql_query("SELECT * FROM showsdb GROUP BY series ASC, ep ASC ORDER BY id ASC") or die (mysql_error()); echo "<table>"; while ($row = mysql_fetch_array($getshows)) { echo "<tr><td><b>$row[name]</b></td></tr>"; $row = mysql_fetch_array($getshows); $count=1; do { if ($count>2) { $i="</tr><tr>"; $count=0;} else { $i="";} echo "<tr><td>Series $row[series] Episode $row[ep]</td></tr>"; echo $i; $count++; } while ($row = mysql_fetch_array($getshows)); } echo "</table>"; So far this code is doing it correctly for just the first show... Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted December 14, 2010 Share Posted December 14, 2010 Untested example (the query is changed, don't use group by): $getshows = mysql_query("SELECT * FROM showsdb ORDER BY name ASC") or die (mysql_error()); $name = ''; echo "<table>"; while($row = mysql_fetch_array($getshows)) { if($row['name'] != $name) { echo "<tr><td><b>".$row['name']."</b></td></tr>"; $name = $row['name']; } echo "<tr><td>Series ".$row['series']." Episode ".$row['ep']."</td></tr>"; } echo "</table>"; Quote Link to comment Share on other sites More sharing options...
spinsfil Posted December 14, 2010 Author Share Posted December 14, 2010 works - thanks Quote Link to comment 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.