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
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.