Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Split Results in two columns using array


LinusIT - 10:01 am on Mar 28, 2011 (gmt 0)


I've got it half working using some completely different code but I've lost the alternating row colours now.

Here's what I've got to split the results up into two columns


<?php
echo"<table cellpadding=\"0\" cellspacing=\"0\" id=\"models\">\n";
echo"<tr><td valign=\"top\" id=\"leftcol\">\n";
$num=mysql_num_rows($result);
$col1=ceil($num/2);
$col2=$num-$col1;
for($j=0;$j<2;$j++)
{
if($j==0)
{
$limit=$col1;
}else{
$limit=$col2;
echo"</td><td valign=\"top\" id=\"rightcol\">\n";
}
echo"<table><tr class=\"headings\"><th class=\"model\">Grade</th><th class=\"weight\">PMT</th></tr>\n";
for($i=0;$i<$limit;$i++)
{
$row=mysql_fetch_assoc($result);
echo"<tr><td>".$row['pricelist_grade']."</td><td>".$row['pricelist_price']."</td></tr>\n";
}
echo"</table>\n";
}
echo"</td></tr></table>\n";
?>


Is there a way of modifying this code to alternate the colours or do I need to use my original code?


Thread source:: http://www.webmasterworld.com/php/4285654.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com