Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts

    Array Problem.. AGAIN!

    Hey,

    Here's the code:

    PHP Code:
    $select mysql_query("SELECT 
                rank,
                alias,
                rating,
                matchesplayed,
                matcheswon,
                matcheslost,
                percentage,
                money,
                id
                FROM users ORDER BY alias"
    );
                
    while (
    $uinfo mysql_fetch_array($select)) {

        
    $plist.=    '<tr>';
        
        foreach(
    $uinfo as $info) {
        
            
    $plist.=    '    <td class="boxcontent" align="center">'.$info.'</td>';
        
        }
        
        
    $plist.=    '</tr>';

    }

    print     
    '<table width="95%" cellpadding="3" cellspacing="1" bgcolor="black">';
    print    
    '    <tr>';
    print     
    '        <td class="boxtitle" align="center">Rank</td>';
    print     
    '        <td class="boxtitle" align="center">Alias</td>';
    print     
    '        <td class="boxtitle" align="center">Rating</td>';
    print     
    '        <td class="boxtitle" align="center">Played</td>';
    print     
    '        <td class="boxtitle" align="center">Won</td>';
    print     
    '        <td class="boxtitle" align="center">Lost</td>';
    print     
    '        <td class="boxtitle" align="center">%</td>';
    print     
    '        <td class="boxtitle" align="center">'.$linfo[money].'</td>';
    print     
    '        <td class="boxtitle" align="center">ID #</td>';
    print    
    '    </tr>';
    print    
    $plist;
    print     
    '</table>'
    For some reason.. it is showing each of the TDs twice.

    EG.

    Instead of one row being say:

    1 Taylor 4 1500

    I'm getting:

    1 1 Taylor Taylor 4 4 1500 1500

    It kind of has me stumped as to why???

    Thanks in advance for any help

  • #2
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    Nevermind!!!

    I'm using mysql_fetch_array instead of mysql_fetch_assoc.

    Fixed and works.. that always happens.. after studying it for so long I realise mistake after I post here lol

  • #3
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts
    PHP Code:
    <?php
    echo '
    <table width="95%" cellpadding="3" cellspacing="1" bgcolor="black">
    <tr>
    <td class="boxtitle" align="center">Rank</td>
    <td class="boxtitle" align="center">Alias</td>
    <td class="boxtitle" align="center">Rating</td>
    <td class="boxtitle" align="center">Played</td>
    <td class="boxtitle" align="center">Won</td>
    <td class="boxtitle" align="center">Lost</td>
    <td class="boxtitle" align="center">%</td>
    <td class="boxtitle" align="center">' 
    $linfo['money'] . '</td>
    <td class="boxtitle" align="center">ID #</td>
    </tr>
    '


    $result mysql_query('SELECT rank, alias, rating, matchesplayed, matcheswon, matcheslost, percentage, money, id FROM users ORDER BY alias');
    while (
    $row mysql_fetch_assoc($result))
    {
        echo 
    '<tr>';
        foreach (
    $row as $value) {echo '<td class="boxcontent" align="center">' $value '</td>';}
        echo 
    ''</tr>';


    echo '
    </table>;
    ?>


  •  

    Posting Permissions

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