Jump to content

while loop help


EchoFool

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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. :D

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.