Help!! How do I Display data in columns instead of rows?

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.

[code]<?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

$speciesname $teamname $shark 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

$speciesname $teamname $drum EOD; }

$bonus_footer ="";

$bonus_wars =<<<BONUS
$bonus_header
$bonus_details
$bonus_details2
$bonus_details3
$bonus_footer
BONUS;

print $bonus_wars;

?>[/code]

What happens if you use GROUP BY species_id instead of GROUP BY team_id?

Then it will just count all of the species_id. It won’t consider that each team is different.

Giving the result

Red Drum = 12
Shark = 1
Black Drum = 1

Sponsor our Newsletter | Privacy Policy | Terms of Service