Page 1 of 1

Array question regarding forms

Posted: Fri Mar 26, 2004 5:59 am
by joespenceley
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.

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&#1111;]' type ='checkbox' value=$playerid </td>";
       echo "<td align=left><input name='textgoals&#1111;]' type='text'></td>";
       echo "</tr>";
&#125;
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.

Code: Select all

foreach($checkplayed as $playerid => $played) &#123; 
       echo $played; 
       echo "<br>";
       echo $textgoals&#1111;$playerid*2]; //  Why $playerid *2????
       echo "<br>";
&#125;
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

Posted: Thu Aug 26, 2004 7:42 am
by Lord Sauron
Please explain how textgoals is created and filled