I want to build a dynamic table so it will go three columns wide then drop to a new row and so on but then if it gets to the end and there are only 2 columns to center them with the above rows
I am using CSV Files for my data.
Code: Select all
<?php
$Name = $_GET['ProdCat'];
$Type = $_GET['ProdType'];
//echo('Insert produts for '.$Name.' catagory of type '.$Type);
//
// determine the page to display based on the type parameter
//
switch ($Type)
{
// image buttons in the displayed in the header of the opening page (HeaderFrame2.php)
case "headerimagebutton":
//echo ('HIB');
include $Name.'.php';
break;
// product catagories displayed on the openingpage (catagoryFrame.php)
default:
// insert dynamic build code here
//echo ('we will build the products page for the catagory '.$Name.' here.');
echo '<table align="center" width="90%" >';
$i = 1;
$HomeFolder=getcwd();
$CatsFolder="Product Catagories/$Name";
$CatsListFile="$Name.csv";
$Caption="";
$Name="";
$Code="";
$Image="";
$file=fopen($HomeFolder."/".$CatsFolder."/".$CatsListFile,"r") or exit("Unable to open file!");
while(!feof($file))
{
$FileLine=fgets($file);
$Array=explode(",",$FileLine);
$Caption=$Array[0];
$Name=$Array[1];
$Code=$Array[2];
$Image=$Array[3];
echo '<table width="90%">';
echo '<td align="center">';
echo '<table border="1">';
echo '<tr align="center">';
echo '<td>';
echo $Caption;
echo'</td>';
echo'</tr>';
echo'</table>';
echo'<br>';
echo'</td>';
if($i==3)
{
print "<table width='90%' align='center'>";
$i = 1;
}
else
{
$i++;
}
}
echo '</table>';
fclose($file);
break;
}
?>The Code in there at the moment worked when it wasnt in a switch case? Would this have anything to do with in??
Cheers Jack