Page 1 of 1

First Attempt advice req'd

Posted: Thu Mar 13, 2008 5:10 pm
by Unicorn13
Hi all,

Newbie here, advice and assistance if you would be so kind.

Ok I am trying to display a products information in a 3 column results style Paginated, each colum 1 record and each record has 5 fields and is displayed as 4 rows in a table with the 4th row split into two columns (subtable).

The information will be kept in flatfile csv, and will nedd to be read into the above, so far I have this,

http://www.ocpdirect.co.uk/bike1/productsgrid.php

Using the following Code:- The problem is I have had to start the counters for the loops at 1, as if I start at 0 as normal it does not display as expected.

Code: Select all

<?php
   echo "<table width='575px' align='center' border='0' cellspacing='0' cellpadding='0'>";
   echo "<tr>";
   for($count=1; $count<=10; $count=$count+1)
   {
   if($count % 3 == 0)
   {
   echo "<td align='center' style='background-color:cyan'>";
   echo "<table width='100%' align='center' border='0' cellspacing='0' cellpadding='0'>";
   echo "<tr>";
   echo "<th style='background-color: yellow;' align='center'>";
   echo "Record: " . $count . " field[0]";
   echo "</th>";
   echo "</tr>";
 
 for($c=1; $c<=3; $c=$c+1)
   {
   if($c == 3)
   {
   echo "<tr>";
   echo "<td style='background-color: #FFD9D9;' align='center'>";
   echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
   echo "<tr>";
   echo "<td width='50%' align='center'>";
   echo "R-" . $count;
   echo ", F-" . $c;
   echo "</td>";
   echo "<td width='50%' align='center'>";
   echo "R-" . $count;
   echo ", F-";
   echo $c+1;
   echo "</td>";
   echo "</tr>";
   echo "</table>";
   echo "</td>";
   echo "</tr>";
   }
   else
   {
   echo "<tr>";
   echo "<td style='background-color: #DFFFFF;' align='center'>";
   echo "R-" . $count;
   echo ", F-" . $c;
   echo "</td>";
   echo "</tr>";
   }
   }
   echo "</table>";
   echo "</td></tr><tr>";
   }
   else
   {
   echo "<td align='center' style='background-color:cyan'>";
   echo "<table width='100%' align='center' border='0' cellspacing='0' cellpadding='0'>";
   echo "<tr>";
   echo "<th style='background-color: yellow;' align='center'>";
   echo "Record: " . $count . " field[0]";
   echo "</th>";
   echo "</tr>";
 
 for($c=1; $c<=3; $c=$c+1)
   {
   if($c == 3)
   {
   echo "<tr>";
   echo "<td style='background-color: #FFD9D9;' align='center'>";
   echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
   echo "<tr>";
   echo "<td width='50%' align='center'>";
   echo "R-" . $count;
   echo ", F-" . $c;
   echo "</td>";
   echo "<td width='50%' align='center'>";
   echo "R-" . $count;
   echo ", F-";
   echo $c+1;
   echo "</td>";
   echo "</tr>";
   echo "</table>";
   echo "</td>";
   echo "</tr>";
   }
   else
   {
   echo "<tr>";
   echo "<td style='background-color: #DFFFFF;' align='center'>";
   echo "R-" . $count;
   echo ", F-" . $c;
   echo "</td>";
   echo "</tr>";
   }
   }
   echo "</table>";
   echo "</td>";
   }
   }
   echo "</table>";
   ?>
The parts that I have not worked :? out yet are Pagination control and how/best way to retrieve this data from the cvs, If anyone can point me in the right direction?

Mnay thanks, and kind regards
Andy

Re: First Attempt advice req'd

Posted: Fri Mar 14, 2008 5:32 pm
by Christopher
You should really look into using a template library (Template lite gets mentioned frequently). There is some pagination code in this forum -- search for "pagination".