// CLOSE TR IF COUNT IS AN EVEN NUMBER
if($row % $qty == "0") {echo '</tr>';}
}
// IF COUNT_PIC IS ODD, THEN ADD EMPTY <td></td>
if($even=="0") {echo '<td></td></tr>';}
echo "</table>";
?>
I can't figure out how to do 4 columns though. Any ideas?
Many thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
HI there.
I'm quite new to PHP so I hope someone can help me with this.
In my excel doc I have 3 columns: Image Filename, Description, Price
Basically, I want to display the information from each row in a single cell of an HTML table that has 4 columns. Like this:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
...and so on.
I've managed it with 2 columns using odd and even numbers, like this:
<?
$pg= 2 //sheet number
$startRow = 3;
$cells = $data->sheets[$pg]['cells'];
// GET TOTAL NUMBER OF rows
$count_pic=$data->sheets[$pg]['numRows'];
// CHECK IF TOTAL NUMBER IS ODD OR EVEN
$qty = "2"; // NUMBER OF TABLE COLUMNS
if ($count_pic % $qty!= 0) {$even="0";} else {$even="1";}
echo "
<table id='product_grid' width='100%' border='0' cellpadding='0' cellspacing='0'>";
for($row=$startRow;$row<=$data->sheets[$pg]['numRows'];$row++){
$Desc = htmlentities($cells[$row][1]);
$Price = htmlentities($cells[$row][2]);
$Filename = $cells[$row][3];
// OPEN TR IF COUNT IS AN ODD NUMBER
if($row % $qty!= 0) {echo '<tr>';}
echo "<td><a class=\"thickbox\" rel=\"group\" href=\"images/product_images/designer/ellen_faith/fullsize/" . $Filename . "\"><img src=\"images/product_images/designer/ellen_faith/thumbnails/" . $Filename . "\" width=\"100\" height=\"100\" /></a><br />" . $Desc . "<br />" . $Price . "</td>";
// CLOSE TR IF COUNT IS AN EVEN NUMBER
if($row % $qty == "0") {echo '</tr>';}
}
// IF COUNT_PIC IS ODD, THEN ADD EMPTY <td></td>
if($even=="0") {echo '<td></td></tr>';}
echo "</table>";
?>
I can't figure out how to do 4 columns though. Any ideas?
Many thanks in advance.