displaying multiple images from DB

Reply

Join Date: Oct 2008
Posts: 2
Reputation: khatter is an unknown quantity at this point 
Solved Threads: 0
khatter khatter is offline Offline
Newbie Poster

displaying multiple images from DB

 
0
  #1
Oct 26th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: displaying multiple images from DB

 
0
  #2
Oct 27th, 2008
Show us what you have then we will help. We won't just give you code.
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2
Reputation: khatter is an unknown quantity at this point 
Solved Threads: 0
khatter khatter is offline Offline
Newbie Poster

Re: displaying multiple images from DB

 
0
  #3
Oct 27th, 2008
This is what I have so far. I have not included the connection to the database.

  1. $houseId = $_GET['houseId'];
  2.  
  3.  
  4.  
  5. $data = mysql_query("SELECT * FROM propertydetails WHERE id = '$houseId'")
  6.  
  7. or die(mysql_error());
  8.  
  9.  
  10. while($info = mysql_fetch_array( $data ))
  11. {
  12.  
  13.  
  14.  
  15. Print "<td class=border width=20% valign=top rowspan=2 >";
  16.  
  17. $piccies = array('pic', 'pic2', 'pic3', 'pic4', 'pic5');
  18.  
  19. $base = 'http://www.propertyadsdirect.com/images';
  20.  
  21. foreach($piccies as $piccy)
  22. {
  23. $photo = $base."/".$info[$piccy] ;
  24.  
  25. if (file_exists($photo))
  26. {
  27. echo "$photo";
  28. echo "<img src=\"/$photo\" /><br />";
  29.  
  30. }

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.
Last edited by peter_budo; Oct 29th, 2008 at 6:18 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: displaying multiple images from DB

 
0
  #4
Oct 27th, 2008
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
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC