i surfed around and couldn't quite find a solution to this, so hopefully some kind and knowledgable soul out there can help me with this.
i have two tables, project_name and project_images. for the purposes of this question, they're defined like so:
project_name
project_id (pri key)
project_name
project_images
image_id (pri key)
imagename
...
project_id (sec key)
now, what i'm trying to do is display the images PER PROJECT in a row. sounds very simple, and it probably is, but i've been struggling with it all afternoon.
here's what i have:
Code: Select all
$sql_projects = "select * from project_name";
$result_projects = @mysql_query($sql_projects,$connection) or die(mysql_error());
while ($row = mysql_fetch_array($result_projects)) {
$project_id = $row['project_id'];
$project_name = $row['project_name'];
$sql_image = "select * from project_images where image_id in (select image_id from project_images where project_id = $project_id)";
$result_image = @mysql_query($sql_image,$connection) or die(mysql_error());
while ($row = mysql_fetch_array($result_image)) {
$imagename = $row['imagename'];
$images .= "<img src='../images/project_images/$imagename' class='imgDisplay' />";
} // end get images
$display .="<tr><td class='underline'>$project_name</td><td class='underline' colspan=2>$images</td></tr>";
}project 1 | image1 image2 image3...
project 2 | image4 image5...
project 3 | image6 image7 image8...
and so on. however, what it's giving me is this:
project 1 | image1 image2 image3...
project 2 | image1 image2 image3 image4 image5
project 3 | image1 image2 image3 image4 image5 image6 image7 image8...
i've tried everything i can think of and i'm at wit's end. can anyone help? many thanks in advance.
--mike
feyd | mmm look at the lovely php colors...
Code: Select all
tags help [/color]