Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Populating select tag
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ktomislav




PostPosted: Sat Jan 09, 2010 7:51 pm   Post subject: Populating select tag

Can you tell me how to populate select tag through for loop?
For example how to add every number form 1 to 10 to select tag (without brute forcing)?

Thanks
Sponsor
Sponsor
Sponsor
sponsor
Ktomislav




PostPosted: Mon Jan 11, 2010 8:13 pm   Post subject: Re: Populating select tag

Well, I'm sorry for double post, but come on guys help me please.
Zren




PostPosted: Mon Jan 11, 2010 8:17 pm   Post subject: RE:Populating select tag

code:

<select>
<?php
        for ($i=1;$i<=10;$i++) {
?>
  <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php
        }
?>
</select>

Not generally a PHP/HTML forum but i know some stuff.
Ktomislav




PostPosted: Mon Jan 11, 2010 8:20 pm   Post subject: Re: Populating select tag

Thank you very much! Very Happy

edit: Nice trick!
Zren




PostPosted: Mon Jan 11, 2010 8:30 pm   Post subject: RE:Populating select tag

No prob. You could do it all in one echo, but it requires a monstrous amount of escape characters.

Thus with PHP, starting and endling blocks don't actually end the script and you can break stuff up like this. It's pretty awesome.
Ktomislav




PostPosted: Mon Jan 11, 2010 8:35 pm   Post subject: Re: Populating select tag

I figured it out I know it can be done in one echo, but thanks anyway.
And yes it is pretty awsome because it is so simple, but kinda so powerful. Very Happy
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: