[thelist] php array help...

John Corry webshot at neoncowboy.com
Tue Mar 20 12:08:04 CST 2001

if ($myrow = mysql_fetch_array($sql_result)) {
		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.

What I want to do is give the <tr> and <td> tags on every other row a
"class" attribute (currently set to $color). So I can give even and odd rows
a different look via the class...

I think I have a grasp on the logic...just not sure how to access teh index
value of the array item to test it, any help?

I'm thinking sort of like this:
	if ($myrow = mysql_fetch_array($sql_result)) {
		if ($myrow[n]%2==0){
		if ($myrow
		print ("<tr class=\"$color\">\n".

...but that doesn't work.

I' dlove any help...thanks,
John Corry

More information about the thelist mailing list