Code: Select all
<?php
define('COLS', 3);
$conn = dbConnect('query');
$sql = 'SELECT * FROM images';
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$pictureid = $_GET['ID'];
$desc = $row['description'];
?>
<table>
<tr>
<?php
// initialize cell counter outside loop
$pos = 0;
do {
//// set caption if thumbnail is same as main image
if ($row['description'] == $row['description']) {
$desc = $row['description'];
}
?>
<td><p><a href="detail.php?ID=<?php echo $row['ID']; ?>"><img src="images/thumbnails/<?php echo $row['file_name']; ?>" /></a></p></td>
<?php
// increment counter after next row extracted
$pos++;
// if at end of row and records remain, insert tags
if ($pos%COLS === 0 && is_array($row)) {
echo '</tr></tr>';
}
}while($row = mysql_fetch_assoc($result)); // end of loop
// new loop to fill in final row
while ($pos%COLS) {
echo '<td> </td>';
$pos++;
}
?>
</tr>
</table>
Code: Select all
<?php
define('COLS', 3);
$conn = dbConnect('query');
$sql = 'SELECT * FROM images';
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$pictureid = $_GET['ID'];
//$desc = $_GET['description'];
$desc = $row['description'];
$link = $row['url'];
<img src="images/fullsize/<?php echo $pictureid; ?><?php echo '.jpg' ?>" />
<?php echo $desc; ?> <?php echo $link; ?>