Jump to content

display images from folder


greg

Recommended Posts

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

[CODE]
$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>';
}
}
[/CODE]
Link to comment
https://forums.phpfreaks.com/topic/24543-display-images-from-folder/
Share on other sites

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):

[code]$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>';
}
}
[/code]

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.