Array question regarding forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joespenceley
Forum Newbie
Posts: 3
Joined: Tue Mar 23, 2004 9:34 pm

Array question regarding forms

Post 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
User avatar
Lord Sauron
Forum Commoner
Posts: 85
Joined: Tue Apr 20, 2004 5:53 am
Location: Tilburg, NL

Post by Lord Sauron »

Please explain how textgoals is created and filled
Post Reply