While loop problems

Posted by Luke on Stack Overflow See other posts from Stack Overflow or by Luke
Published on 2010-06-15T17:52:41Z Indexed on 2010/06/15 18:02 UTC
Read the original article Hit count: 281

Filed under:
|

I have put together the following code, the problem is that each while loop is only returning one set of data.

$result = mysql_query("SELECT date FROM ".TBL_FIXTURES." WHERE compname = '$comp_name' GROUP BY date");
    $i = 1;
    echo "<table cellspacing=\"10\" style='border: 1px dotted' width=\"300\" bgcolor=\"#eeeeee\">";
    while ($row = mysql_fetch_assoc($result)) 
    {
        $date=date("F j Y", $row['date']);
        echo $date;

        echo "
        <tr>
        <td>Fixture $i - Deadline on $date</td>
        </tr>
        ";
        $result = mysql_query("SELECT * FROM ".TBL_FIXTURES." WHERE compname = '$comp_name' AND date = '$row[date]' ORDER BY date");
        while ($row = mysql_fetch_assoc($result))
        {
            extract ($row);
            echo "
            <tr>
            <td>$home_user - $home_team V $away_user - $away_team</td>
            </tr>
            ";
        }
        $i++;

    }
    echo "</table>";

I should get many dates, and then each set of fixture below. At the moment, the first row from the first while loop is present, along with the data from the second while loop.

However, it doesn't continue? Any ideas where I can correct this? Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql