Jump to content

[SOLVED] Uniquely naming table cells based on $counter value


PHP_Idiot

Recommended Posts

I have a table that generates rows based on user input and it displays the number of players, and the points earned for each position. then is a text field for membership numbers. Following that I want to look up FirstName & LastName as a sanity check.

 

Before I do that I understand that I need to uniquely name each row under First & Last Name, probably based on the $counter value.

 

Here is my tables current code

 

for ( $counter = 1; $counter <= $PlayerNo; $counter += 1) 
{
echo "<tr><td align='center' valign='center'>";
echo $counter;
echo "</td><td align='center' valign='center'>";
echo $points = isset($pointsArray[$counter]) ? $pointsArray[$counter] : 25; ;
echo "</td><td align='center' valign='center'>";
echo '<input name="MembershipNo" type="text" size="7" maxlength="7">';
echo "</td><td align='center' valign='center'>";
echo '<input name="FirstName $counter" type="text" size="15" maxlength="7">';
echo "</td><td align='center' valign='center'>";
echo '<input name="LastName[$counter]" type="text" size="15" maxlength="7">';
echo "</td></tr>";

 

I have tried both of the following but without success:

echo "</td><td align='center' valign='center'>";
echo '<input name="FirstName $counter" type="text" size="15" maxlength="7">';
echo "</td><td align='center' valign='center'>";
echo '<input name="LastName[$counter]" type="text" size="15" maxlength="7">';
echo "</td></tr>";

Just to be clear I don't want to change the display at this moment in time, just change the name as viewed in 'view source' eg name="FirstName" (and LastName) changed to name="FirstName1", name="FirstName2" etc for the full value of the $counter.

 

Many Thanks

echo "</td><td align='center' valign='center'>";

  echo "<input name='FirstName".$counter."' type='text' size='15' maxlength='7'>";

  echo "</td><td align='center' valign='center'>";

  echo "<input name='LastName".$counter."' type='text' size='15' maxlength='7'>";

  echo "</td></tr>";

 

Should do it.

Thats perfect thanks a lot  :)

 

I Don't suppose you can help with the next step can you?

I need to get the FirstName and LastName cells to up date with the names that correspond to the membership number typed on the same row, Ideally I want this update to occur as soon as the membership number is typed in rather than having to fill them all and click a button to perform the query.

 

The test form can be seen at www.gbpokerclub.co.uk/testform.php, fill this in and hit the create form button and you will see the table I'm talking about.

 

Many Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.