display x amount of columns wide
Posted: Fri Sep 30, 2005 1:42 am
Hi,
The following code works, I have just pulled out the part that display x amount of columns wide without the pagination .. Im sure I dont have the x amount of columns code correct altho it seems to be working.
Is it correct?
Thanks
The following code works, I have just pulled out the part that display x amount of columns wide without the pagination .. Im sure I dont have the x amount of columns code correct altho it seems to be working.
Is it correct?
Code: Select all
<table border="0" cellspacing="0" cellpadding="10" align="center">
<?php
if($_GET['page'] == NULL) {
$page = 1;
} else {
$page = $_GET['page'];
}
$max_results = 8;
$numcols = 4;
$numcolsprinted = 0;
$from = (($page * $max_results) - $max_results);
$count = mysql_query("SELECT * FROM gallery_photos");
$sql = mysql_query("SELECT * FROM gallery_photos WHERE photo_category='".$_GET['cid']."' LIMIT $from, $max_results");
$totalEntries = mysql_num_rows($count);
while($row = mysql_fetch_array($sql)) {
if($numcolsprinted == $numcols) {
echo "<tr>\n</tr>\n";
$numcolsprinted = 0;
}
echo '<td>';
if(mysql_num_rows($result) == 0) {
echo '<font class="txt"><b>No images in this category yet</b></font>';
} else {
echo '<a href="../index.php?pages=sh_image&pid='.$row['photo_id'].'&page='.$_GET['page'].'"><img src="'.$images_dir.'/tb_'.$row['photo_filename'].'" border="1"></a>';
if ($_SESSION['user_level'] == 3) {
echo '<br><font class="txt"><a href="../index.php?pages=edit_photo&category_name='.$category_name.'&photo_id='.$row['photo_id'].'">Edit/Delete</a></font>';
}
}
echo '</td>';
$numcolsprinted++;
}
$colstobalance = $numcols - $numcolsprinted;
for ($i=1; $i<=$colstobalance; $i++) {
}
echo "<td></td>\n";
?>
</table>