Jump to content

Drop down boxes with PHP.


vidyashankara

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.
Link to comment
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?
Link to comment
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.