Jump to content

Displaying data in Columns??


Skipjackrick

Recommended Posts

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.

 

table2.bmp

 

 

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....

 

table1.bmp

 

 

 

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;
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.