$sql = "SELECT tbl_album.id AS album_id, tbl_album.name AS album_name, tbl_album.location AS album_folder, ";
$sql .= "tbl_album.description AS album_description, tbl_images.id AS images_id, tbl_images.name AS images_name, ";
$sql .= "tbl_images.location AS images_location, tbl_images.description AS images_description ";
$sql .= "FROM `tbl_album`, `tbl_images` WHERE tbl_album.id = '".$id."' AND tbl_album.id = tbl_images.album_id";
$query = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($query);
$row = mysql_fetch_array($query);
if($num_rows == 0)
{
?>
<p class="mytext2">There are no pictures for this album at the moment. Please
try again later. </p>
<?php
}
?>
<p>Album: <?php echo $row['album_name']; ?></p>
<table width="600" border="0" align="center">
<?php
for ($x = 0; $x < $num_rows; $x++)
{
$add = 0;
?>
<tr>
<?php
$image = "gallery/".mysql_result($query, $x, 'album_folder')."/".mysql_result($query, $x, 'images_location');
?>
<td width="202">
<a href="images.php?id=<?php echo mysql_result($query, $x, 'images_id'); ?>"><img src="<?php echo $image; ?>" width="200" height="150" border="0"></a>
</td>
<?php
if($x + 1 < $num_rows)
{
$image = "gallery/".mysql_result($query, $x+1, 'album_folder')."/".mysql_result($query, $x+1, 'images_location');
?>
<td width="374">
<a href="images.php?id=<?php echo mysql_result($query, $x+1, 'images_id'); ?>"><img src="<?php echo $image; ?>" width="200" height="150" border="0">
</a></td>
<?php
$add = 1;
}else{
?>
<td> </td>
<?php
if ($x + 2 < $num_rows)
{
$image = "gallery/".mysql_result($query, $x+2, 'album_location')."/".mysql_result($query, $x+2, 'images_location');
?>
<td width="160">
<a href="images.php?id=<?php echo mysql_result($query, $x+2, 'images_id'); ?>"><img src="<?php echo $image; ?>" width="200" height="150" border="0"></a></td>';
<?php
$add = 2;
}else{
?>
<td> </td>
<?php
$x = $x + $add;
?>
</tr>
<?php
}
?>
</table>
<?php
}
}
I re-wrote the code and fixed the parse errors...Thanks for the code...i really appreciate it.
But, it repeats the images: take a look: http://www.scaria.info/fbla/gallery.php?id=1
What went wrong?
here's the database details:
[code]
-- Table structure for table tbl_album
CREATE TABLE tbl_album (
id tinyint(4) NOT NULL auto_increment,
name text NOT NULL,
location text NOT NULL,
default text NOT NULL,
description mediumtext NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
--
-- Dumping data for table tbl_album
INSERT INTO tbl_album VALUES (1, 'SLC 2005', 'SLC 2005', 'IMG_2230.jpg', 'SLC 2005 in Edison, NJ');
--
-- Table structure for table tbl_images
CREATE TABLE tbl_images (
id tinyint(4) NOT NULL auto_increment,
name text NOT NULL,
album_id tinyint(4) NOT NULL default '0',
location text NOT NULL,
description text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=5 ;
--
-- Dumping data for table tbl_images
INSERT INTO tbl_images VALUES (1, 'pauls speech', 1, 'IMG_2231.jpg', 'description');
INSERT INTO tbl_images VALUES (2, 'slkjdf', 1, 'IMG_2230.jpg', 'sfd');
INSERT INTO tbl_images VALUES (3, 'sdf', 1, 'IMG_2232.jpg', 'dfadsf');
INSERT INTO tbl_images VALUES (4, 'IMG_2233.jpg', 1, 'IMG_2233.jpg', 'IMG_2233.jpg');
[/code]