Page 1 of 1

looping images stored in a folder and paths in mysql

Posted: Fri Jul 01, 2011 2:50 am
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>';
}
}
?>

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

Posted: Fri Jul 01, 2011 4:00 am
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

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

Posted: Fri Jul 01, 2011 7:25 am
by godiloug
Thanks for ur help but the images are not still showing

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

Posted: Fri Jul 01, 2011 9:22 am
by dhenick
try to echo $image it is show image and path or not?