Jump to content

Archived

This topic is now archived and is closed to further replies.

glenelkins

List Boxes

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]

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

×

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.