looping images stored in a folder and paths in mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
godiloug
Forum Newbie
Posts: 2
Joined: Fri Jul 01, 2011 2:28 am

looping images stored in a folder and paths in mysql

Post by godiloug »

I'm building an application where users can register their names and upload their pictures. my script for uploading the images to the folder and saving the paths to mysql is working very well. the problem is how to retrieve the images and display them when someone wants to see all registered members. please can someone help out.

below is my code:

<?php
if (isset($_POST['SearchCate'])){
include 'conn.php';

$Category = $_POST['Category'];

//save the name of image in table
$ShowSalesPro = mysql_query("select * from items_for WHERE Category='$Category'") or die(mysql_error());

//retrieve all image from database and store them in a variable
while($props=mysql_fetch_array($ShowSalesPro))
{
$img_name = $props['uploadPic'];
$image = "<img src='pictures/$img_name' />";

//store all images in one variable
$all_img = $all_img.$image;

echo'<table width="435" border="0" bgcolor=#FFE8C6 align="center">'.
'<tr>'. '<td class="LabeResult">'.'Property Category'.'</td>'.
'<td class="NewLabCSS">'.$props['Category'].'</td>'.
'</tr>'.
'<tr>'. '<td class="LabeResult">'.'Property Name'.'</td>'.
'<td class="NewLabCSS">'.$props['ItemName'].'</td>'.
'</tr>'.
'<tr>'. '<td class="LabeResult">'.'Picture'.'</td>'.
'<td>'.'<img height="150" width="200" '.$image.'</td>'.
'</tr>'.
'<tr>'. '<td class="LabeResult">'.'Brief Description'.'</td>'.
'<td class="NewLabCSS">'.$props['Description'].'</td>'.
'</tr>'.
'<tr>'.'<td class="LabeResult">'.'Selling Price'.'</td>'.
'<td class="NewLabCSS">'.$props['Cost'].'</td>'.
'</tr>'.
'<tr>'. '<td class="LabeResult">'.'Property Location'.'</td>'.
'<td class="NewLabCSS">'.$props['Location'].'</td>'.
'</tr>'.
'</table>';
}
}
?>
dhenick
Forum Newbie
Posts: 19
Joined: Tue Oct 20, 2009 10:46 am
Location: Yogyakarta, Indonesia
Contact:

Re: looping images stored in a folder and paths in mysql

Post by dhenick »

change

Code: Select all

$image = "<img src='pictures/$img_name' />";
to

Code: Select all

$image = "pictures/".$img_name;
and then change

Code: Select all

'<tr>'. '<td class="LabeResult">'.'Picture'.'</td>'.
'<td>'.'<img height="150" width="200" '.$image.'</td>'. 
to

Code: Select all

'<tr>'. '<td class="LabeResult">'.'Picture'.'</td>'.
'<td>'.'<img height="150" width="200" src ='.$image.'</td>'. 
hope this will be help :D
godiloug
Forum Newbie
Posts: 2
Joined: Fri Jul 01, 2011 2:28 am

Re: looping images stored in a folder and paths in mysql

Post by godiloug »

Thanks for ur help but the images are not still showing
dhenick
Forum Newbie
Posts: 19
Joined: Tue Oct 20, 2009 10:46 am
Location: Yogyakarta, Indonesia
Contact:

Re: looping images stored in a folder and paths in mysql

Post by dhenick »

try to echo $image it is show image and path or not?
Post Reply