EchoFool Posted August 8, 2008 Share Posted August 8, 2008 Hey, im looking to find out how to make a table in while loops to make a 50 by 50 co-ordinates map. Like the below example: (0,0) (0,1) (0,2) (1,0) (1,1) (1,3) But have no idea how to do it. Using while loops.. i tried this: Code: <table width="500" border="1" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="10" align="center" class="blackBold">X</td> <?php $var2 = 0; While($var2 < 51){ ?> <td width="10" align="center" class="blackBold"><?=$var2?></td> <?php $var2 = $var2 + 1; } ?> </tr> <?php $var = 0; While($var < 51){ ?> <tr> <td width="10" align="center" class="blackBold"><?=$var?></td> </tr> <?php $var = $var + 1; } ?> </table> But this went horribly incorrect. How do i get it correctly so all the cells are labeled correctly? Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/ Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Try two nested for loops. And don't use short tags. >_< Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611913 Share on other sites More sharing options...
EchoFool Posted August 8, 2008 Author Share Posted August 8, 2008 Why not use short tags? Should the main loop be doing rows or columns ? Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611920 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Short tags aren't enabled on all servers and are generally considered bad programming practice for that reason. And the main loop would be doing rows. for($row=0;$row<=50;$row++) { for ($column=0;$column<=50;$column++) { echo "($row, $column) "; } echo "<br />"; } Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611923 Share on other sites More sharing options...
Jabop Posted August 8, 2008 Share Posted August 8, 2008 Short tags aren't enabled on all servers and are generally considered bad programming practice for that reason. Didn't you and I argue about this? default php.ini files have their short tags enabled. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611926 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Short tags aren't enabled on all servers and are generally considered bad programming practice for that reason. Didn't you and I argue about this? default php.ini files have their short tags enabled. Actually it was you, I, and PFMabismad (or however you spell and capitalize his name). xD They do, but it's against recommendation and some web hosts have them turned off (based on some posts here). Let's not get into this again. xD Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611930 Share on other sites More sharing options...
Jabop Posted August 8, 2008 Share Posted August 8, 2008 Okay that is something I'll have to take up with zend or php then. If they have a recommended ini file, why would they even have a default? Why not make the default what is already recommended? Short tags are just fine, despite what anyone says. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611933 Share on other sites More sharing options...
EchoFool Posted August 8, 2008 Author Share Posted August 8, 2008 I see no security threat for short tags so why would they have them disabled by default. Anyway, i have bared that in mind and will ask the server i look into before buying them that they allow short tags. Thanks for the warning. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611934 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Okay that is something I'll have to take up with zend or php then. If they have a recommended ini file, why would they even have a default? Why not make the default what is already recommended? Short tags are just fine, despite what anyone says. Because they can't force you to do anything. PLENTY of different types software with ini files also contain a .ini-recommended and .ini-default file. You wouldn't get very far with taking up a common practice with Zend or PHP. =/ Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611935 Share on other sites More sharing options...
Jabop Posted August 8, 2008 Share Posted August 8, 2008 I said it more for the sarcasm value, because, recommending short tags disabled but enabling them in the default config is stupid and always will be. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611938 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 I said it more for the sarcasm value, because, recommending short tags disabled but enabling them in the default config is stupid and always will be. They don't feel like handling the complaints from people when all of their code no longer works. They have their reasons, they aren't as stupid as you think. That's why they took so long to take register_globals out. They needed to prepare everyone. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611944 Share on other sites More sharing options...
EchoFool Posted August 8, 2008 Author Share Posted August 8, 2008 Still don't understand why they don't always have it ? Whats so bad about short tags? Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611945 Share on other sites More sharing options...
Jabop Posted August 8, 2008 Share Posted August 8, 2008 Still don't understand why they don't always have it ? Whats so bad about short tags? Nothing is wrong with short tags and again they are enabled by default php.ini. The main argument is that it is bad for portability. Short tags are good and you should use them just for the sake of people that complain about them. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611946 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 You really shouldn't use them if you DO hope for some sort of portability, or if you're developing an application that you plan to distribute. >_> Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611947 Share on other sites More sharing options...
wildteen88 Posted August 8, 2008 Share Posted August 8, 2008 Lets get some facts straight short tags has been disabled by default . It has never been enabled on a fresh install of php. By a fresh install, I mean installing PHP manually. Not a an install from XAMPP or WAMP or whatever pre-configured package you use. These packages have nothing to do with the PHP Foundation. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611948 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Yeah, that's what I thought. I didn't have time to go download and make sure though. I remember them being off by default on a clean download. Whatever. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611950 Share on other sites More sharing options...
EchoFool Posted August 8, 2008 Author Share Posted August 8, 2008 I see, well my code isn't to be distributed anywhere other than my site so its portability won't be that big of scope to worry i guess. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611951 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Ah, I just remembered about my copy of PHP that I use for extension building. Here we are: ;;;;;;;;;;;;;;;;;;;; ; Language Options ; ;;;;;;;;;;;;;;;;;;;; ; Enable the PHP scripting language engine under Apache. engine = On ; Enable compatibility mode with Zend Engine 1 (PHP 4.x) zend.ze1_compatibility_mode = Off ; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized. ; NOTE: Using short tags should be avoided when developing applications or ; libraries that are meant for redistribution, or deployment on PHP ; servers which are not under your control, because short tags may not ; be supported on the target server. For portable, redistributable code, ; be sure not to use short tags. short_open_tag = Off ; Allow ASP-style <% %> tags. asp_tags = Off =) Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611956 Share on other sites More sharing options...
Jabop Posted August 8, 2008 Share Posted August 8, 2008 I ran a little sudo apt-get install php5 on a virtual box, and what do you know, short_open_tag = On Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611957 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 That's your Debian's package of it. Not a clean install. Go compile and tell me what you get. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611959 Share on other sites More sharing options...
Jabop Posted August 8, 2008 Share Posted August 8, 2008 We've successfully hijacked this thread, let's not argue about potatos and potatos here anymore. If you want to chat, DarkWater, aim me. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611961 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 =P Maybe some other day. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611962 Share on other sites More sharing options...
EchoFool Posted August 8, 2008 Author Share Posted August 8, 2008 although you hijacked.. people may want to see what evidence you have either way... its still educational Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611963 Share on other sites More sharing options...
wildteen88 Posted August 8, 2008 Share Posted August 8, 2008 Agreed thread is going of topic. Thread locked. Link to comment https://forums.phpfreaks.com/topic/118837-while-loop-help/#findComment-611995 Share on other sites More sharing options...
Recommended Posts