PDA

View Full Version : Need to show the images from database into table


swetha123
11-14-2008, 06:08 AM
Can any one tell me.. Iam using Dreamweaver CS4
I need to display the images from my database into a table and my images are in the this folder
C:\webserver\Apache2\abc_Images\images
but in the code this line is not working
$cimage="/images/".$obj->path;
if i give the complete path like this
$cimage="C:\webserver\Apache2\abc_Images\images\".$obj->path;
then i can see the images in the table
please tell me what wrong iam doing
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
function connect()
{
$dbhost='localhost';
$dbuser='root';
$dbpass='swetha';
$conn= mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'.mysql_error());
$dbname='abc';
mysql_select_db($dbname);
return $conn;
}
?>
<body>
<table border="1" align="center" height="290" width="533" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<?php
$c=connect();
$query2="select style from styles";
$sql=mysql_query($query2);
$result2=mysql_num_rows($sql);
$query="select path from styles";
$result=mysql_query($query);
echo mysql_num_rows($result);
echo '<table align="center" width="55%" height="60%" BORDERCOLOR="#C6C6C6" >'; for($r=1;$r<=3;$r++)
{
echo '<tr>';
for($d=1;$d<=3;$d++)
{
$obj=mysql_fetch_object($result);
$imageSrc=$obj->path;
$cimage="/images/".$obj->path;
echo '<td border="2" width="15px" height="25px" name="img1"><img width="187px" height="109px"
src='.$cimage.'></td>';
}
echo '</tr>';
}
echo '</table>';
?>
</td>
</tr>
</table>
</body>
</html>

davidj
11-14-2008, 06:55 AM
you need to debug your code if its not working

did you copy and paste this or did you write it