Jump to content

If - Else Quick Help


Skipjackrick

Recommended Posts

I am having trouble displaying data as I would like. 

 

The following code displays data when

 

SUM(points) = 0

 

Well, there are a sheetload of people that haven't scored points and I don't want to include them on the standings page if they have zero points.

 

For example something like this in beginners terms,

 

if SUM(points) > 0 { display result}  else { don't display result }

 

I tried using an if else statement in there somewhere but I kept getting parse errors.  I am not sure how to go about doing it right.

 

<?php
$query_sum = "SELECT 
	angler,
	SUM(points)
	FROM submit
	WHERE yyyy=2008 AND region_id=1
	GROUP BY angler
	ORDER BY SUM(points)DESC"; 

$result = mysql_query($query_sum) or die(mysql_error());

$kayakwars_header=<<<EOD
<h2><Center>Kayak Wars 2008 Angler Standings (Western Gulf)</center></h2>
<table width='400' align='center'>
<tr>
	<th>Rank</th>
	<th>Angler</th>
	<th>Points</th>
</tr>

EOD;

$rank=1;
while($row = mysql_fetch_array($result))
{
$angler = $row['angler'];
$points = $row['SUM(points)'];

$kayakwars_details .=<<<EOD
<tr>
	<td align='center'>$rank</td>
	<td align='center'>$angler</td>
	<td align='center'>$points</td>
</tr>
EOD;
$rank++;
}
$kayakwars_footer ="</table>";

$kayak_wars =<<<KAYAKWARS
	$kayakwars_header
	$kayakwars_details
	$kayakwars_footer
KAYAKWARS;

print $kayak_wars;
?>

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.