vidyashankara Posted June 16, 2006 Share Posted June 16, 2006 Lets say i have a variable $model if $model is 17, then i want a drop down box with 1,2,3,... 17 as the options how do i do that?right now i have the following code[code]echo "<select name=segidi> ";for ($i=0; $i<$model1; $i++) {echo "<option value=$model1[$i]>$model1[$i]";}echo "</select>";[/code]But this outputs 1 and 7 as the options. Link to comment https://forums.phpfreaks.com/topic/12196-drop-down-boxes-with-php/ Share on other sites More sharing options...
AndyB Posted June 16, 2006 Share Posted June 16, 2006 [code]echo "<option value='". $i. "'>". $i. "</option>";[/code] Link to comment https://forums.phpfreaks.com/topic/12196-drop-down-boxes-with-php/#findComment-46459 Share on other sites More sharing options...
vidyashankara Posted June 16, 2006 Author Share Posted June 16, 2006 [!--quoteo(post=384764:date=Jun 16 2006, 04:47 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 16 2006, 04:47 PM) [snapback]384764[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]echo "<option value='". $i. "'>". $i. "</option>";[/code][/quote]that outputs 0,1,2,... 16, how do i get it to output 1,2,3..17 ?[code]for ($i=1; $i<$model; $i++) {echo "<option value=$i>$i";}[/code]I did the aboce one and it outputs 1,2,3,.. 16 not 17what do i do? Link to comment https://forums.phpfreaks.com/topic/12196-drop-down-boxes-with-php/#findComment-46468 Share on other sites More sharing options...
joquius Posted June 16, 2006 Share Posted June 16, 2006 for ($i=1; $i<=$model; $i++) {echo "<option value=$i>$i";} Link to comment https://forums.phpfreaks.com/topic/12196-drop-down-boxes-with-php/#findComment-46487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.