looping images stored in a folder and paths in mysql
Posted: Fri Jul 01, 2011 2:50 am
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>';
}
}
?>
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>';
}
}
?>