calumogg
10-24-2007, 10:42 AM
Hi, I am using this script to display pictures from a database, the PHP script is supposed to display them in a table, but the pictures are not displaying or linking, here is a example of what is happening http://www.calumogg.co.uk/galleries.php?gallery=landscapes
Here is the code I am using:
<?php
$gallery = $_GET['gallery'];
$host="*****"; // Host name
$username="*****"; // Mysql username
$password="*****"; // Mysql password
$db_name="*****"; // Database name
$tbl_name="$gallery"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$query = "SELECT * FROM $tbl_name ORDER BY file_name DESC";
$result = mysql_query($query) or die('Error, query failed');
echo '<table width="100%" border="0" align="center" cellpadding="5">';
$colsPerRow = 4;
// width of each column in percent
$colWidth = (int)(100/$colsPerRow);
while ($row = mysql_fetch_assoc($result)) {
if ($i % $colsPerRow == 0) {
// start a new row
echo '<tr>';
}
echo '<td width="' . $colWidth . '%"><a href="' . $rows['large'] . '" rel="lightbox[' . $gallery . ']" title="' . $rows['file_name'] . '"><img src="' . $rows['thumbnail'] . '"></a></td>';
if ($i % $colsPerRow == $colsPerRow - 1) {
// end this row
echo '</tr>';
}
$i += 1;
}
// print blank columns
if ($i % $colsPerRow != 0) {
while ($i++ % $colsPerRow != 0) {
echo '<td width="' . $colWidth . '%"> </td>';
}
echo '</tr>';
}
echo '</table>';
?>
Thanks in advance for any help :)
Here is the code I am using:
<?php
$gallery = $_GET['gallery'];
$host="*****"; // Host name
$username="*****"; // Mysql username
$password="*****"; // Mysql password
$db_name="*****"; // Database name
$tbl_name="$gallery"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$query = "SELECT * FROM $tbl_name ORDER BY file_name DESC";
$result = mysql_query($query) or die('Error, query failed');
echo '<table width="100%" border="0" align="center" cellpadding="5">';
$colsPerRow = 4;
// width of each column in percent
$colWidth = (int)(100/$colsPerRow);
while ($row = mysql_fetch_assoc($result)) {
if ($i % $colsPerRow == 0) {
// start a new row
echo '<tr>';
}
echo '<td width="' . $colWidth . '%"><a href="' . $rows['large'] . '" rel="lightbox[' . $gallery . ']" title="' . $rows['file_name'] . '"><img src="' . $rows['thumbnail'] . '"></a></td>';
if ($i % $colsPerRow == $colsPerRow - 1) {
// end this row
echo '</tr>';
}
$i += 1;
}
// print blank columns
if ($i % $colsPerRow != 0) {
while ($i++ % $colsPerRow != 0) {
echo '<td width="' . $colWidth . '%"> </td>';
}
echo '</tr>';
}
echo '</table>';
?>
Thanks in advance for any help :)