Daney11 Posted March 17, 2009 Share Posted March 17, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/149746-solved-forms/ Share on other sites More sharing options...
trq Posted March 17, 2009 Share Posted March 17, 2009 Can you at least attempt to make your code readable? This isn't perl. You might also want to let us know what 'doesn't work' means. Quote Link to comment https://forums.phpfreaks.com/topic/149746-solved-forms/#findComment-786342 Share on other sites More sharing options...
Daney11 Posted March 17, 2009 Author Share Posted March 17, 2009 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/149746-solved-forms/#findComment-786343 Share on other sites More sharing options...
Daney11 Posted March 17, 2009 Author Share Posted March 17, 2009 Fixed. Needed to change the i value to something different and change if ($val==$Squad_PlayerRow['id']) { to if ($val==$Squad_PlayerRow['squad_number']) { Quote Link to comment https://forums.phpfreaks.com/topic/149746-solved-forms/#findComment-786348 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.