| | |
displaying multiple images from DB
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 2
Reputation:
Solved Threads: 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.
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.
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
Show us what you have then we will help. We won't just give you code.
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Oct 2008
Posts: 2
Reputation:
Solved Threads: 0
This is what I have so far. I have not included the connection to the database.
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.
php Syntax (Toggle Plain Text)
$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.
Last edited by peter_budo; Oct 29th, 2008 at 6:18 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
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
edit $photo before you set it as src, then echo it
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
![]() |
Similar Threads
- How to replace missing images with default image (PHP)
- Data from mysql in a 3 columns table (PHP)
- Problem with display parent & child nodes if XML not follows an Hierar Struc. in c# (XML, XSLT and XPATH)
- displaying and capturing mutiple images (C#)
- Refreshing a Tkinter Canvas Multiple Times: (Python)
- Multiple images to a single bmp/jpg image (Visual Basic 4 / 5 / 6)
- AOL - Is it worth it? (Web Browsers)
Other Threads in the MySQL Forum
- Previous Thread: how can i sort and reterive file path as string in mysql table?
- Next Thread: MySQL Clustering and InnoDB
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groupware hiring hyperic images innerjoins insert ip joebrockmeier join keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization






