SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2011
    Location
    Colorado, USA
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    results in table

    I have a query select all rounds where username = '$user'
    this is my code
    PHP Code:
    $result mysql_query("SELECT * FROM rounds WHERE username = '$user'");
            echo 
    "<table width='600' border='1'>
                    <tr>
                        <th>Course</th>
                        <th>Date Played</th>
                        <th>Par</th>
                        <th>Strokes</th>
                        <th>+/-</th>
                    </tr>"
    ;
                while (
    $row=mysql_fetch_array($result)) {
                    echo 
    "<tr>
                            <td align='center'>"
    ,$row['courseplayed'],"</td>
                            <td align='center'>"
    ,$row['dateplayed'],"</td>
                            <td align='center'>"
    ,$row['par'],"</td>
                            <td align='center'>"
    ,$row['score'],"</td>
                            <td align='center'></td>
                          </tr>
                         </table>"
    ;
                         ;}
                
    ?> 
    it pulls all the data correctly but only puts one of the results in the table the rest are under the table. What am I missing to get all the results in the table?

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,343
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    Your closing TABLE tag is included in the 'while' loop; it gets printed each iteration.
    If you "View Source" on the output page you will see this.
    Move the closing 'table' tag to a single 'echo' statement at the end of this code and you will be in good shape.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2011
    Location
    Colorado, USA
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ParkinT View Post
    Your closing TABLE tag is included in the 'while' loop; it gets printed each iteration.
    If you "View Source" on the output page you will see this.
    Move the closing 'table' tag to a single 'echo' statement at the end of this code and you will be in good shape.
    Thanks ParkinT


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •