I'm trying to have my code display all pictures for a specific ID, this is the current code that is only showing a single picture to be displayed, how can I get it to display the others as well?

thanks

<?php
        $id=$_REQUEST['id'];
		$result=mysql_query("SELECT * FROM gallery_work_thumbnail WHERE id=$id");
        while($row=mysql_fetch_array($result))
        {
		?>


<?php echo $row['img_title'];?>
       
<img src="<?php echo UPLOAD_URL.'gallery/'.$row['image_name']; ?>"  id="thumb<?php echo $thumblocate[$i]['id'] ;?>"  border="0" class="photo" width="100%"   height="60%" /> 

<?php echo $row['img_des']; ?>
								
		<?php } ?>

What do you mean by "display all pictures for a specific id"? If you want to display all the pictures in the table, that's doable. But typically an id is unique to a picture, so each id can only have one picture.

Hi, yes I would like to display all pictures in the table

this is the code that I have that is used to display the image (single image)

<?php if($_GET['workid']!=''){    ?>

    <?php
    $id=$_REQUEST['workid'];
    $result=mysql_query("SELECT title FROM work_db WHERE id='$_GET[workid]' ");
                        if (!is_resource($result)) {
    // There has been an error
    echo mysql_error();
    }
    while($row = mysql_fetch_array($result))
  {
    $name=$row['title'];
    }
		$locationthumb=get_specified_content('gallery_work_thumbnail','display_order','project_id='.$_REQUEST['workid']);
		
		if(count($locationthumb)>0){for($i=0;$i<count($locationthumb);$i++) {
		  $find=$locationthumb[$i]['id'];
		  $result=mysql_query("SELECT * FROM gallery_work_thumbnail WHERE id='$find' ");
                        if (!is_resource($result)) {
    // There has been an error
    echo mysql_error();
    }
    while($row = mysql_fetch_array($result))
  {
    $name=$row['img_title'];
    
    }
?>
<a href="http://www.website.xxx/thumbs/<?php  echo toAscii($name); ?>-<?php echo $locationthumb[$i]['id'] ;?>.html">

<img src="thumb.php?src=<?php echo UPLOAD_URL.'workgallery/'.$locationthumb[$i]['image_name']; ?>&h=118&w=147&zc=1" alt=""/></a>


<?php }}else{ echo '';	}?>

<?php }

?>

Assuming, as you say, that the script successfully displays one image, it appears the problem may lie in your getspecificcontent() function. Notice this:

if(count($locationthumb)>0){

If there is only one element in the array that getspecifiedcontent() returns, there will only be one image displayed. Look at the code in the function or post it here...


Additionally, this:

$id=$_REQUEST['workid'];
    $result=mysql_query("SELECT title FROM work_db WHERE id='$_GET[workid]' ");
                        if (!is_resource($result)) {
    // There has been an error
    echo mysql_error();
    }
    while($row = mysql_fetch_array($result))
  {
    $name=$row['title'];
    }

Appears to be entirely redundant, as $name is reassigned before anything is done to it.

Side notes:
If the code posted appears the same in your file(format) you may want to consider learning some PHP style conventions to improve the readability of your code. If not, ignore this. Style examples:

while($condition == true) {
     if($condition2 == true) {
          do_something();
     } 
     else {
          do_something_else();
     }
}

// VS:

while($condition==true){if($condition2==true){do_something()}else{do_something_else();}

// OR:
while($condition==true)
{
if($condition2==true)
{
do_something();
}
else
{
do_something_else();
}

Not majorly important, but helps if:
A) You have to deal with larger scripts
B) Someone else has to read your code(like right now)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.