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; ?> Quote Link to comment 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"; Quote Link to comment 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.... Quote Link to comment 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; Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.