Skipjackrick Posted March 27, 2008 Share Posted March 27, 2008 I am having an extremely difficult time trying to figure out how to display some data in columns rather than in rows. Ok, I have the following data displayed like this. But I want the same exact data displayed like this. Does anybody have any pointers? Seems like a simple task to me? But I can't figure it out.... This is the code that I am using. <?php //connect to MySQL $link = mysql_connect("localhost", "*********", "**********") or die ("Check your server connection, could not connect to database"); //make sure we're using the right database mysql_select_db ("**********"); $bonus_header=<<<EOD <h2><Center>Total Number of Catches</center></h2> <table width='400' border='0' cellpadding='2' cellspacing='2' align='center'> <tr> <th>Species</th> <th>Team</th> <th>Total</th> </tr> EOD; $query_red = "SELECT species_id, team_id, COUNT(species_id) FROM submit WHERE species_id=1 GROUP BY team_id ORDER BY COUNT(species_id)DESC"; $result2 = mysql_query($query_red) or die(mysql_error()); while($row = mysql_fetch_array($result2)) { $team_id = $row['team_id']; $species_id = $row['species_id']; $redfish = $row['COUNT(species_id)']; $bonus_details .=<<<EOD <tr> <td align='center'>$speciesname</td> <td align='center'>$teamname</td> <td align='center'>$redfish</td> </tr> EOD; } $query_shark = "SELECT species_id, team_id, COUNT(species_id) FROM submit WHERE species_id=4 GROUP BY team_id ORDER BY COUNT(species_id)DESC"; $result3 = mysql_query($query_shark) or die(mysql_error()); while($row = mysql_fetch_array($result3)) { $team_id = $row['team_id']; $species_id = $row['species_id']; $shark = $row['COUNT(species_id)']; $bonus_details2 .=<<<EOD <tr> <td align='center'>$speciesname</td> <td align='center'>$teamname</td> <td align='center'>$shark</td> </tr> EOD; } $query_drum = "SELECT species_id, team_id, COUNT(species_id) FROM submit WHERE species_id=5 GROUP BY team_id ORDER BY COUNT(species_id)DESC"; $result4 = mysql_query($query_drum) or die(mysql_error()); while($row = mysql_fetch_array($result4)) { $team_id = $row['team_id']; $species_id = $row['species_id']; $drum = $row['COUNT(species_id)']; $bonus_details3 .=<<<EOD <tr> <td align='center'>$speciesname</td> <td align='center'>$teamname</td> <td align='center'>$drum</td> </tr> EOD; } $bonus_footer ="</table>"; $bonus_wars =<<<BONUS $bonus_header $bonus_details $bonus_details2 $bonus_details3 $bonus_footer BONUS; print $bonus_wars; ?> Quote Link to comment Share on other sites More sharing options...
Skipjackrick Posted March 27, 2008 Author Share Posted March 27, 2008 I have been reading and trying to figure this out but I am still not sure if I am headed the right direction. Would I use the following function?? mysql_fetch_row I am pretty sure that mysql_fetch_array is not going to work for me the way I have it listed above. All I need is a little kick. I can figure it out if I have a heading. 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.