glenelkins Posted June 8, 2006 Share Posted June 8, 2006 HiIf 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] Quote Link to comment https://forums.phpfreaks.com/topic/11484-list-boxes/ Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 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]<?phpecho '<select size="3" multiple>'; for ($i=0;$i<2;$i++) { echo '<option>' . $i . '</option>' . "\n"; }echo '</select>';?>[/code]All of them worked here. Quote Link to comment https://forums.phpfreaks.com/topic/11484-list-boxes/#findComment-43154 Share on other sites More sharing options...
glenelkins Posted June 8, 2006 Author Share Posted June 8, 2006 HiIt 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. Quote Link to comment https://forums.phpfreaks.com/topic/11484-list-boxes/#findComment-43164 Share on other sites More sharing options...
.josh Posted June 8, 2006 Share Posted June 8, 2006 [!--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... Quote Link to comment https://forums.phpfreaks.com/topic/11484-list-boxes/#findComment-43258 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.