Jump to content

Recommended Posts

Hey guys.

 

Im having a problem.

 

Using the below code works:

<input type='text' size='10' name='squad_number[$i]' value='{$Squad_PlayerRow['squad_number']}' />

 

However i want to use a dropdown box instead. Using the below code doesnt work:

<select name="squad_number[$i]"><?php for ($i=0; $i<=99; $i++) { if($i<10) { $val="0$i"; } else { $val=$i; } echo "<option value=\"$val\""; if ($val==$Squad_PlayerRow['squad_number']) { echo " selected"; } echo ">$val</option>"; } ?></select>

 

Any ideas why the drop down doesnt work?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/149746-solved-forms/
Share on other sites

Basically.... I want to be able to select numbers from 00-99 using a dropdown menu. I have this code below which you can input a number and it works fine and updates all the players within my database.

 

echo "<input type='text' size='10' name='squad_number[$i]' value='{$Squad_PlayerRow['squad_number']}' />";

 

However, using the below peice of code. The drop down menu shows numbers from 00-99 but does not update all the players in the database.

 

echo "<select name='squad_number[$i]'>";
for ($i=0; $i<=99; $i++) { if($i<10) { $val="0$i"; } else { $val=$i; } 
echo "<option value='$val'"; 
if ($val==$Squad_PlayerRow['id']) { 
echo " selected"; } 
echo ">$val</option>";
}
echo "</select>";

Link to comment
https://forums.phpfreaks.com/topic/149746-solved-forms/#findComment-786343
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.