I want to display information from my database in two columns.  I run
into a problem when there are three records. Another table data cell is
produced containing template material.  Does anyone know a quick
solution to this problem?  Code below:
 
$cols = 2;
 $cell_count = 0;
 if($numrows < $cols){
  $cells = $numrows;
 }
 else{
  $cells = $cols;
 }
 $test = $numrows/$cols;
 if($test <= 0){
  $rows = 1;
 }
 else{
  $rows = round($test);
 }
 for($i = 0; $i < $rows; $i++){
  echo"<tr>";
  for($j = 0; $j < $cells; $j++){
   $r=$lower_news->fobject();
   $l_news_id = $r->id;
   $l_news_title = $r->title;
   $l_news_date = $r->date;
   $l_news_username = $r->username;
   $l_news_image = $r->image;
   $l_news_intro = $r->intro;
   $l_news_views = $r->views;
   echo"<td width=\"50%\" align=\"left\">\n";
   echo"<table cellpadding=\"0\" cellspacing=\"0\">\n";
   echo"<tr>\n";
   echo"<td align=\"left\" valign=\"top\"><a
href=\"javascript://void(0)\" OnClick=\"NewsPic('News',
'$hse_root_web_addr"."news/picture.php?pic=$l_news_image')\"><img
class=\"news_headline\" width=\"64\" height=\"48\"
src=\"$hse_root_web_addr"."news/img/$l_news_image\" alt=\"Click for
bigger version!\" /></a></td>\n";
   echo"<td valign=\"top\">\n";
   echo"<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">\n";
   echo"<tr>\n";
   echo"<td align=\"left\" valign=\"top\"
class=\"lower_news_headline\"><a
href=\"$hse_root_web_addr"."news/?id=$l_news_id\">$l_news_title</a></td>
\n";
   echo"</tr>\n";
   echo"<tr>\n";
   echo"<td align=\"left\" class=\"info\"><b>Published:</b>
$l_news_date<br /><b>Author:</b> $l_news_username</td>";
   echo"</tr>\n";
   echo"</table>\n";
   echo"</td>\n";
   echo"</tr>\n";      
   echo"</table>\n";
   echo"</td>\n";
  }
  echo"</tr>";
 }
?>

Reply via email to