Passing a value around

Hi. I’m in the process of bodging my way through a project and I’ve hit a snag. I’ve got a database that’s used for an image gallery (plogger) and i’m attempting to pull some images out of it for another application. I’m almost there, in tests I’ve been able to get some images out and display them as I wish but I’m having trouble getting them based on the variable that I need to work with. (the album name).

I have a table (plogger_albums) which contains the columns ‘name’ (this is the variable I am sending) and the column ‘id’ (this is a variable I need to identify the image paths). In my code below I am successfully getting this ‘id’ based on the ‘name’ I send in and I’m able to print it to the screen. The trouble I’m having is using this ID in another table to retrieve the image paths…

In another table (plogger_pictures) the two columns I’m working with are ‘parent_album’ (this maches the ‘id’ result from plogger_albums) and ‘path’ (this contains the url of image I want). I’m having trouble comparing the my variable with this table to retrieve the paths, can somebody please identify what I’m doing wrong here? Thanks in advance!

<?php

echo “<h2>Gallery</h2>”;

$con = mysql_connect("#####.co.uk","#####","######");
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

mysql_select_db("########", $con);

$val = $_GET[‘client’];

$result2 = mysql_query(“SELECT id FROM plogger_albums
WHERE name=’$val’”);

while($row2 = mysql_fetch_array($result2))
{
print’

‘.$row2[‘id’].’
';

}

$result3 = mysql_query(“SELECT * FROM plogger_pictures
WHERE parent_album=’$result2’”);

while($row3 = mysql_fetch_array($result3))
{

print’

<a href=“http://www.mysite.tv/gallery/images/’.$row3[‘path’].’” rel=“lightbox[groupme]”>
<img style=“margin:10px;” src=“http://www.mysite.tv/gallery/images/’.$row3[‘path’].’” width=“228” height=“171”>
</a>’;

}

print’
</div>’;

mysql_close($con)

?>