Array question regarding forms
Posted: Fri Mar 26, 2004 5:59 am
I'm new to php and still finding my way around it but in this instance I have managed to get my code to work.
What I am interested in finding out is if it's meant to work this way.
The following code generates a form from a SQL query.
I am quite happy with the code to retrieve the value of the checkbox array but it is with retrieving the text from 'textgoals' that i find odd. As I step through the checkbox array I must multiply the array position by 2 to retrieve the related textbox array.
Is this *2 multiplication by design or is there something wrong with my code that needs to be addressed.
Any feed back would be appreciated.
Cheers,
Joe
What I am interested in finding out is if it's meant to work this way.
The following code generates a form from a SQL query.
Code: Select all
while ($player = mysql_fetch_array($get_players_result)) {
$playerid = $playerї'playerid'];
$name = $playerї'name'];
echo "<tr>";
echo "<td align=left>$name</td>";
echo "<td align=left><input name='checkplayedї]' type ='checkbox' value=$playerid </td>";
echo "<td align=left><input name='textgoalsї]' type='text'></td>";
echo "</tr>";
}Code: Select all
foreach($checkplayed as $playerid => $played) {
echo $played;
echo "<br>";
echo $textgoalsї$playerid*2]; // Why $playerid *2????
echo "<br>";
}Any feed back would be appreciated.
Cheers,
Joe