Re: $i vs. $r

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

 



Hello all....

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\">");

include("$site_path/common/code/directory_format_name.php"); // Gets the name Formatter echo ("\n<a href=\"/directory/".$row['sup_link']."/\"><img src=\"/ images/directory/".$row['sup_picture']."\" border=\"0\"></a>"); echo ("<br><a href=\"/directory/".$row['sup_link']."/\">$full_name</ a>");

		echo ("\n</td>");
		
		if (($r >= "$website_total") AND (is_int(($r+2)/3)))
		{	echo ("<td>&nbsp;</td><td>&nbsp;</td></tr>");	}
		elseif (($r >= "$website_total") AND (is_int(($r+1)/3)))
		{	echo ("<td>&nbsp;</td></tr>");	}		
		elseif (is_int(($r)/3))
		echo ("\n</tr>");

		$r++;

	}
	echo ("</table>");


--
Kevin Murphy
Webmaster - Information and Marketing Services
Western Nevada Community College
www.wncc.edu
(775) 445-3326


On Mar 27, 2006, at 3:11 PM, Jasper Bryant-Greene wrote:

Kevin Murphy wrote:
Does anyone have a clue why using this code doesn't work:

Please specify what "doesn't work" means in this case :)

$i = 0;
while ($row = mysql_fetch_array($result))
    {           echo ("Blah blah blah");
        $i++;
    }

$r = 0;
while ($row = mysql_fetch_array($result))
    {           echo ("Blah blah blah");
        $r++;
    }

Those two blocks of code are for all intents and purposes identical, and indeed probably end up as exactly the same opcodes.

Jasper

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


--
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