Jump to content

Printing title to match group of photos. Help needed!


cturner

Recommended Posts

I am wanting to display a title and description to match a group of photos. The result from my code displays this:

Title1

Description1

Photo1

Title1

Description1

Photo2

 

Here is my code:

require "config.php";
// more code here
$sql = "SELECT *
    FROM `livestock_photos`
    WHERE parent_id = '".mysql_real_escape_string($row['id'])."'";
  if($debug == TRUE)
    echo '<p>DEBUG3: '.$sql.'</p>';
  $result2 = mysql_query($sql)
    or die ('Could not query because: ' . mysql_error());

  while ($row2 = mysql_fetch_assoc($result2))
  {	
	echo '<strong>'.$row2['title'].'</strong><br />';
	echo $row2['description']."<br />";
     
    echo '<a href="javascript:void(0)" onClick="popWin(\''.$images_location_large.$row2['filename'].'.htm\', \'\', \''.$popup_width.'\', \''.$popup_height.'\')"><img src="'.$images_location.$row2['photos'].'" border="0" /></a> ';
$parent_id = $row2['parent_id'];		
}
// more code here
mysql_close();

 

My table structure is:

Livestock_photos

photos_id // the auto-incremented number

parent_id // is the livestock listing's number

title

description

filename // displays like this: livestock photo

photos // displays like this: livestock photo.jpg

 

You will be able to see why I have used filename and photos in the database, by looking at my code above. A photos row only displays one thing not multiple things. Can someone please help me solve this problem asap? Thanks in advance.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.