Hi. I'm trying to print a numbered list of items read from an xml feed.
With the code below I'm having the same number for every item in the list (1). Can you please tell me what I'm doing wrong?
<?
function myRecordHandler($record)
{
$i = 1;
?>
<tr>
<td><? print $i;?>.</td>
<td><? print $record["PEOPLE-PLAYER"];?></td>
<td><font color="#000000"><? print $record["PEOPLE-TEAM_NAME"];?></font></b></td>
<td align="center" width="20"><acronym title="Games played"><font color="#000000"><? print $record["PEOPLE-GOALS"];?></font></b></acronym></td></tr>
</td>
</tr>
<?
$i++;
}
?>
Hi,
What you need to do is declare $i as global, and only initialise it to 1 once, outside the loop. Try something like this:
<?
$i = 1;
function myRecordHandler($record)
{
global $i;
?>
<tr>
<td><? print $i;?>.</td>
<td><? print $record["PEOPLE-PLAYER"];?></td>
<td><font color="#000000"><? print $record["PEOPLE-TEAM_NAME"];?></font></b></td>
<td align="center" width="20"><acronym title="Games played"><font color="#000000"><? print $record["PEOPLE-GOALS"];?></font></b></acronym></td></tr>
</td>
</tr>
<?
$i++;
}
?>
Hope this helps!
Cheers,
David.