[thelist] php array help...

Sowers, Matthew (CSC) Sowers at VOLPE.DOT.GOV
Tue Mar 20 12:28:09 CST 2001


What'd I'd do is set a flag at the beginning of the PHP, and then do a logical choice on then when it comes time.

<<<CODE START>>>

// Here's the flag

$myFlag=0;
if ($myrow = mysql_fetch_array($sql_result)) {
	do{

// Switch statement that will set class and reset the flag
		switch($myFlag){
			case 0:
				$color="evenrow";
				$myFlag=1;
				break;
			case 1:
				$color="oddrow";
				$myFlag=0;
				break;
		}

		if ($myrow
		print ("<tr class=\"$color\">\n".
		"<td class=\"$color\">".$myrow['size']."</td>\n".
		"<td class=\"$color\">".$myrow['luff_length']."</td>\n".
		"<td class=\"$color\">".$myrow['boom_length']."</td>\n".
		"<td class=\"$color\">".$myrow['mast']."</td>\n".
		"<td class=\"$color\">".$myrow['mcs']."</td>".
		"<td class=\"$color\">".$myrow['imcs']."</td></tr>");
		}
		while ($myrow = mysql_fetch_array($sql_result));
		echo "</table>";
		} else {
	echo "Sorry, no records were found.";

>Here's my code, which retrieves a group of records from a database (with a
>mere 7 fields) and writes the contents into a table.
>I' dlove any help...thanks,
>John Corry


Try this and see if it works, it's what I typically use for that sort of thing.

--Matt




More information about the thelist mailing list