Jump to content


Photo

display images from folder


  • Please log in to reply
2 replies to this topic

#1 greg

greg
  • Members
  • PipPipPip
  • Advanced Member
  • 49 posts

Posted 20 October 2006 - 01:42 PM

Hi,
I have a folder named "picture" with pictures of each member. Some members has one pic, others has more than one. I also have a table named "member_picture" with the file name that correspond to each member. In the following code, I want to display the member images in the second row ($row["pic"]).

Thank you for your help.
greg

$sql="select u.id, u.name, u.number, u.accept, p.pic, p.id from member_user u left join member_picture p on u.id=p.id where u.accept=1";
$results=mysql_query($sql);
$rows=mysql_num_rows($results);
if ($rows==0)
	$cont.='<tr><td class="bodytxt" align="center" colspan="2">There is no  existant member</td></tr>';
else
	{
	while ($row=mysql_fetch_array($results))
		{
		$cont.='<tr>
		<td class="bodytxt" align="left"><a href="viewdetails.php?id='.$row["id"].'&nam='.$name.'"><b>'.$row["name"].'</b></a></td>
		<td class="bodytxt" align="left"> '.$row["pic"].'</b></a></td>
		<td class="bodytxt" align="center"><a href="denynew.php?id='.$row["id"].'"> deny </a></td>
		<td class="bodytxt" align="center"><a href="deletemember.php?id='.$row["id"].'" onClick="return confirm(\'Are you sure you want to delete this member?\');">delete</a></td>
			</tr>';
	}
}


#2 Psycho

Psycho
  • Moderators
  • Move along, nothing to see here
  • 11,892 posts
  • LocationCanada

Posted 20 October 2006 - 03:52 PM

You don't state if you are getting any errors with your code. I will assume that your code is working and that the value of 'pic' is the name of the image. In that case to display the picture(s) you could do the following (note the 2nd TD line):

$sql="select u.id, u.name, u.number, u.accept, p.pic, p.id from member_user u left join member_picture p on u.id=p.id where u.accept=1";
$results=mysql_query($sql);
$rows=mysql_num_rows($results);
if ($rows==0)
	$cont.='<tr><td class="bodytxt" align="center" colspan="2">There is no  existant member</td></tr>';
else
	{
	while ($row=mysql_fetch_array($results))
		{
		$cont.='<tr>
		<td class="bodytxt" align="left"><a href="viewdetails.php?id='.$row["id"].'&nam='.$name.'"><b>'.$row["name"].'</b></a></td>
		<td class="bodytxt" align="left"><img src=\"PATHTOPICTUREFOLDER\'.$row["pic"].'\"></b></a></td>
		<td class="bodytxt" align="center"><a href="denynew.php?id='.$row["id"].'"> deny </a></td>
		<td class="bodytxt" align="center"><a href="deletemember.php?id='.$row["id"].'" onClick="return confirm(\'Are you sure you want to delete this member?\');">delete</a></td>
			</tr>';
	}
}

The quality of the responses received is directly proportional to the quality of the question asked.

I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net

#3 greg

greg
  • Members
  • PipPipPip
  • Advanced Member
  • 49 posts

Posted 21 October 2006 - 02:10 AM

Yes, the code does not give me errors.
Your change works perfectly!
Thank you for your help
greg




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users