0

Hi guys

I am building a website which allows people to advertise their property online for free. I allow people to upload up to 5 images to my database.

I store the name of the file in the database and the image itself is stored elsewhere on the server.


I store the file names in the database table under, pic, pi2,pic3,pic4,pic5

I need to check if a filename exists in pic,pic2 etc and if one is present then the image is displayed and if not the code moves on.

I have been goven help from other forums but the code I have been goven has not worked.

Any help would be appreciated.

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by dickersonka
0

This is what I have so far. I have not included the connection to the database.

$houseId = $_GET['houseId']; 



$data = mysql_query("SELECT * FROM propertydetails WHERE id = '$houseId'") 

or die(mysql_error()); 
 

while($info = mysql_fetch_array( $data )) 
{ 



Print "<td class=border width=20% valign=top rowspan=2 >";

 $piccies = array('pic', 'pic2', 'pic3', 'pic4', 'pic5'); 

$base = 'http://www.propertyadsdirect.com/images';  

foreach($piccies as $piccy)
{ 
$photo = $base."/".$info[$piccy] ; 

if (file_exists($photo))
{
echo "$photo";
echo "<img src=\"/$photo\" /><br />"; 

}

The idea is that the database table holds the filename of each image in pic, pic2 etc. (ie housse.jpg). If a filename is present then the image is displayed. I printed out $photo to see what result I woudl get and it displays the correct pathway for the image but nothing is displayed.

I can't see what is wrong.
Thanks for any help you can give, as I have been trying to sort this out for weeks.

0

if you are saying $photo prints out the path, but you are placing a slash in src

edit $photo before you set it as src, then echo it

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.