0

Good evening

I'm looking for yet more assistance, and hope someone is able to point me in the right direction.

I'm trying to produce a format for our tipping competition, whereby people who fail to complete their entries are shown a) without a result in the profit column, and b) are highlighted with a grey background. I have attempted to write the code, but it's not producing the right effect:

                <?php

                $query = "  SELECT SUM(comptipsterselections.profit) as Profit, comptipsterselections.stable, comptipsterboard.link
                            FROM comptipsterselections INNER JOIN comptipsterboard
                            ON comptipsterselections.stable=comptipsterboard.stable 
                            AND comptipsterselections.comp=comptipsterboard.comp 
                            WHERE comptipsterselections.comp = 'aintree 2011'
                            GROUP BY comptipsterselections.stable, comptipsterboard.link
                            ORDER BY SUM(comptipsterselections.profit) DESC";


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

                // Set-up table

                            echo "<table class='english' border='1' cellpadding='4' cellspacing='0' width='75%'>";
                            echo "<tr class='toprow'> <th>Stable</th> <th>Daily Profit</th></tr>";


                // Print out result
                            while($row = mysql_fetch_array($result)){

                            $link='/site/competitions/tipster'.$row[link];

                            if ($row[completed] == 'no') {

                            echo "<tr><td bgcolor='#C0C0C0'>";
                            echo "<a href='$link'>";
                            echo $row[stable];
                            echo "</td><td bgcolor='#C0C0C0'>";
                            echo "";
                            echo "</td></tr>";
                            }
                            else
                            {
                            echo "<tr><td>";
                            echo "<a href='$link'>";
                            echo $row[stable];
                            echo "</td><td>";
                            echo " £". $row[Profit];
            }

            echo "</td></tr>"; 
            } 
            echo "</table>";?>

Any assistance in getting the right effect would be very much appreciated.

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by Borderline
0

Do not write inline outdated inline styles. Just use css and apply a class attribute to the relevant entry.

0

I don't know about fixing the error, but part of your query seemed to be with regard to formatting output. That was my 2p (additional advice, if you want).

But delving into your php:

if ($row[completed] == 'no') {

where is the 'completed' field in the SQL? Can't see it.

0

Great, thanks! That did the job. If this is of any use, the updated code looks like this:

                $query = "  SELECT SUM(comptipsterselections.profit) as Profit, comptipsterselections.stable, comptipsterboard.link,    
                            comptipsterboard.completed
                            FROM comptipsterselections INNER JOIN comptipsterboard
                            ON comptipsterselections.stable=comptipsterboard.stable 
                            AND comptipsterselections.comp=comptipsterboard.comp 
                            WHERE comptipsterselections.comp = 'aintree 2011'
                            GROUP BY comptipsterselections.stable, comptipsterboard.link
                            ORDER BY SUM(comptipsterselections.profit) DESC";


                $result = mysql_query($query) or die(mysql_error());
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.