Jump to content

List Boxes


glenelkins

Recommended Posts

Hi

If i use the following HTML is creates a nice list box:

[code]
<select size="3" multiple>
  <option>1</option>
  <option>2</option>
  <option>3</option>
</select>
[/code]

So why does this not work??:

[code]
<select size="3" multiple>
  <?
  for ($i=0;$i<2;$i++) {
    ?>
    <option><? echo $i; ?></option>
    <?
  }
  ?>
</select>
[/code]
Link to comment
Share on other sites

I don't know, because it works here. Maybe if you use the conventional start tag (<?php instead of <?) ?

[code]<select size="3" multiple>
  <?php
  for ($i=0;$i<2;$i++) {
    ?>
    <option><?php echo $i; ?></option>
    <?php
  }
  ?>
</select>[/code]

In fact I don't like the idea of hopping in and out of PHP:

[code]<select size="3" multiple>
  <?php
  for ($i=0;$i<2;$i++) {
    echo '<option>' . $i . '</option>' . "\n";
  }
  ?>
</select>[/code]

Or :

[code]<?php

echo '<select size="3" multiple>';

  for ($i=0;$i<2;$i++) {
    echo '<option>' . $i . '</option>' . "\n";
  }

echo '</select>';

?>[/code]

All of them worked here.
Link to comment
Share on other sites

Hi

It actually makes no difference with the <? and <?php tags (at all!!! they are the same)

Its working now, i pasted the code...wierd!! when i type it it does not like it. Unless its my computer adding in invisible characters, iv had that before!!



..and now its working when typed.
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
It actually makes no difference with the <? and <?php tags (at all!!! they are the same)
[/quote]
actually, they are different. not all servers support [code]<?[/code] if your server supports it, fine and dandy, but say you wanna move to a new server, and guess what, it doesn't support it. since you like hopping in and out of php, you'd have an awful lot of editing to 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.