Re: $i vs. $r --> coding style ....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Philip Hallstrom wrote:
I simplified the code a bit, and I am guessing that it was too much. Below is the complete code that works fine. The weird part is, the part that I have the question on, is if I change $r to $i, it doesn't work anymore. $i doesn't count up as it should and instead gives me some unpredictible results..... as it goes down the list sometimes its sequential (1,2,3 but never more than 3), other times its just the number 2 over and over).


    $r = 1;

    while ($row = mysql_fetch_array($website_result))
    {
        if (is_int(($r+2)/3))
        {    echo ("\n<tr>");    }
        echo ("\n<td align=\"center\" valign=\"bottom\">");

purely aesthetic but maybe your eyes will hurt less if you cut down
on the backslashes (and unrequired parentheses) ....

	   echo "\n", '<td align="center" valign="bottom">';

[echo is special in that it is not a function! rtm for more info ;-)]


        include("$site_path/common/code/directory_format_name.php");


I'm going to guess that "$site_path/common/code/directory_format_name.php" uses $i to do something else on it's own and is therefore messing up your $i. At least that's where I'd start looking.


ditto!

also I'd suggest that doing this include again and again inside
this loop is a bad idea ... maybe try refactoring the code in the include file
so that you can use/call it as a function (which has it's own scope and is garanteed
_not_ to screw the vars in the calling scope)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux