Jump to content


Photo

Drop down boxes with PHP.


  • Please log in to reply
3 replies to this topic

#1 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 16 June 2006 - 09:32 PM

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

echo "<select name=segidi> ";

for ($i=0; $i<$model1; $i++) {

echo "<option value=$model1[$i]>$model1[$i]";


}
echo "</select>";

But this outputs 1 and 7 as the options.

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 16 June 2006 - 09:47 PM

echo "<option value='". $i. "'>". $i. "</option>";

Legend has it that reading the manual never killed anyone.
My site

#3 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 16 June 2006 - 09:59 PM

[!--quoteo(post=384764:date=Jun 16 2006, 04:47 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 16 2006, 04:47 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
echo "<option value='". $i. "'>". $i. "</option>";
[/quote]


that outputs 0,1,2,... 16, how do i get it to output 1,2,3..17 ?

for ($i=1; $i<$model; $i++) {

echo "<option value=$i>$i";


}

I did the aboce one and it outputs 1,2,3,.. 16 not 17

what do i do?

#4 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 16 June 2006 - 10:39 PM

for ($i=1; $i<=$model; $i++) {

echo "<option value=$i>$i";

}
z..z..z..z..z..z..z..z..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users