Skipjackrick Posted March 25, 2008 Share Posted March 25, 2008 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 More sharing options...
Barand Posted March 25, 2008 Share Posted March 25, 2008 <?php $query_sum = "SELECT angler, SUM(points) as total FROM submit WHERE yyyy=2008 AND region_id=1 GROUP BY angler HAVING total > 0 ORDER BY total DESC"; Link to comment https://forums.phpfreaks.com/topic/97871-if-else-quick-help/#findComment-500784 Share on other sites More sharing options...
Skipjackrick Posted March 25, 2008 Author Share Posted March 25, 2008 Whoa COOL TRICK!! I am still Tiny Grasshopper.... Link to comment https://forums.phpfreaks.com/topic/97871-if-else-quick-help/#findComment-500786 Share on other sites More sharing options...
BlueSkyIS Posted March 25, 2008 Share Posted March 25, 2008 your parse error is probably the lone EOD; Link to comment https://forums.phpfreaks.com/topic/97871-if-else-quick-help/#findComment-500787 Share on other sites More sharing options...
Skipjackrick Posted March 25, 2008 Author Share Posted March 25, 2008 your parse error is probably the lone EOD; Thanks, Everything Works Perfect! Link to comment https://forums.phpfreaks.com/topic/97871-if-else-quick-help/#findComment-500788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.