Jump to content

Archived

This topic is now archived and is closed to further replies.

greg

display images from folder

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]

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Yes, the code does not give me errors.
Your change works perfectly!
Thank you for your help
greg

Share this post


Link to post
Share on other sites

×

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.