Re: while-do +array

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

 



On Wed, 2007-10-31 at 13:02 +0200, Steven Macintyre wrote:
> Hiya,
> 
> I have the following code ... which only seems to result in one item ...
> which is incorrect ... can anyone spot my problem?

Your subject line says "while-do" + array, following code contains a
"do-while" loop. We can't debug the script very well without a sample
input since we don't know how many times the loop "should" run. To debug
yourself, try using print_r() to see exactly what the following line of
code produces:

    $options = explode(",", $armbase);

It's also useful for you to know that the list() function in your while
clause has return value void, AKA null, and so it will always be a false
statement and your loop will terminate on the first check.

Cheers,
Rob.



> 	if ($armbase != "") {
> 		$options = explode(",", $armbase);
> 		$text .=  '<table ><tr>';
> 		$get_endRow = 0;
> 		$get_columns = 8;
> 		$get_hloopRow1 = 0;
> 
> 		do {
> 			if($get_endRow == 0  && $get_hloopRow1++ != 0) {
> 				$text .= '<tr>';
> 				$text .= '<td valign="top" width="60">';
> 				$text .= "<img
> src='".e_BASE."images/options/armbase/".$value."'>";
> 				$text .= '</td>';
> 				$get_endRow++;
> 			}
> 			if($get_endRow >= $get_columns) {
> 				$text .=  '</tr>';
> 				$get_endRow = 0;
> 			}
> 		} while(list($key,$value) = each($options));
> 
> 		if($get_endRow != 0) {
> 			while ($get_endRow < $get_columns) {
> 				$text .=  '<td>&nbsp;</td>';
> 				$get_endRow++;
> 			}
> 			$text .=  '</tr>';
> 		}
> 
> 		$text .=  '</table>';
> 
> 	}
> 
> The purpose of the code is to create 8 colums and populate based on the
> total results returned from the while-do check
> 
> Thanks in advance
> 
> Steven
> 
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

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