FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » populating a list box problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: populating a list box problem [message #171121 is a reply to message #171119] Sat, 25 December 2010 20:51 Go to previous messageGo to previous message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma:
Senior Member
Jerry Stuckle wrote:
> On 12/25/2010 6:27 AM, Peter wrote:
>> In article<4d14f5a0$0$31600$bed64819(at)gradwell(dot)net>,
>> denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com says...
>>> On 24/12/10 19:09, richard wrote:
>>>> rather than having a god awful long mess of "options" in the code, I
>>>> would
>>>> like to populate the listbox by using php.
>>>
>>> Something like this maybe
>>>
>>> echo "<select name=\"pulldown1\">\n";
>>> $i = count($options);
>>> while ($i --) echo "<option value=\"$i\">{$options[$i]}</option>\n";
>>> echo "</select>\n";
>>>
>>> Not really sure what you're describing in the rest of your post though.
>>>
>>> Rgds
>>>
>>> Denis McMahon
>>>
>>
>> Just quickly, I noticed both you and Jerry included \n (newline
>> character) in your output. Is there a specific reason for adding that?
>> Would have thought it was completely unnecessary.
>>
>
> Unnecessary - but practical. Makes the source more readable when you
> need to view it.
>

I would just like to add that you should pick one way of using
quotes. Single quotes are just fine in HTML. The example below is much
easier (readable) on the eyes in my opinion. Just keep in mind that \n
only works inside double quotes.


echo "<select name='pulldown1'>\n";
$i = count($options);
while ($i--) echo "<option value='$i'>{$options[$i]}</option>\n";
echo "</select>\n";

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: New start-up seeking a programmer (vesting only!)
Next Topic: My first PHP Script...
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 01 01:21:03 GMT 2024

Total time taken to generate the page: 0.06520 seconds