Jump to content

Archived

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

vidyashankara

Drop down boxes with PHP.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
[code]echo "<option value='". $i. "'>". $i. "</option>";[/code]

Share this post


Link to post
Share on other sites
[!--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 17

what do i do?

Share this post


Link to post
Share on other sites

×

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.