...

View Full Version : Array Problem.. AGAIN!



Taylor_1978
07-12-2005, 01:01 AM
Hey,

Here's the 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 :thumbsup:

Taylor_1978
07-12-2005, 01:06 AM
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

devinemke
07-12-2005, 01:12 AM
<?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>';
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum