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
https://forums.phpfreaks.com/topic/97871-if-else-quick-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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