0

I know, Here is something wrong in Image Output Section. Please, Help me to correctly show the images to 3rd no. column.

<html>
<head>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body>
<?php
include ('cont.php');
$result = mysql_query("SELECT * FROM productinput") or die(mysql_error());

echo "<center>";
	echo"<table width='500' border='1' cellspacing='0' cellpadding='0'>";
echo" <tr>";
echo"	<th>Brand</th>";
echo"   <th>Model</th>";
echo"   <th>Image</th>";
echo"   <th>Description</th>";
echo"   <th>Price</th>";
echo"  </tr>";
while ($row=mysql_fetch_array($result))
{
echo "<tr>";

echo "<td>";
echo $row['brand'];
echo "</td>";	

echo "<td>";
echo $row['model'];
echo "</td>";

echo "<td>";
echo $row['image'];
echo "</td>";

echo "<td>";
echo $row['descr'];
echo "</td>";

echo "<td>";
echo $row['price'];
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "</center>";
?>
</body>
</html>
4
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by aynamohol
0

I am able to input product image to the database. But, I also able to output everything from the database without image. What can i do now?

0

So how are you saving the images?
- Saving images to the server and storing the location in the database
or
- Storing the image as a BLOB type in the database

0

do you understand what Will is saying to you? he means put $row inside an image tag, like this

echo "<img src='".$row['image']."' />";

Edited by vaultdweller123: n/a

0

If you are using a BLOB field to store the images (By the way, I would not do this. The filesystem is the best place to store files, not the database, but it's up to you) you will need another script to get the data and output it as an image.

Assuming your images are in jpeg format, then the following should work. This is an example, you will need to change it for your script.

1. Change the image output:
(You will need a new file, I'll call it getimage.php for this, you will also need a unique identifier in your database such as an ID column with an auto increment, I called this $row)

echo "<td>";
echo "<img src=\"getimage.php?image_id=" . $row['id'] . "\" />";
echo "</td>";

2. Then in the getimage.php file (or whatever you named it) you will need another database call to get the row using the ID in the query string, you know how to do a SELECT so I will not detail this.
To make PHP output the image as an image, you need to set the header, then you can echo the result from the db:

header('Content-type: image/jpg');
echo $row['image'];

Edited by Will Gresham: n/a

0

If you just store the path of the image file then you could use:

echo "<img src='".$row['image']."' />";

If you used as a blob field then follow as Will said.

header('Content-type: image/jpg');
echo $row['image'];
0

Thank you both,
I learned several topics from you. I really delighted with you. I am checking. I was not with my computer. I am checking now.
Thanks
sam

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.