i need help with PHP code?

Jaclyn S

New member
below is some code that shows products thats in a SQL datatbase - how do i get to display an image from the database?

$output[] = '<tr>';
print "<table border = 4 >";
print " <tr><th>Name</th><th>Type</th><th>Description</th><th>Quantity Avaliable</th><th>Price</th><th>Image</th><th>Add to Cart!</th></tr>";
while ($row = mysql_fetch_array($result))
{
print "<tr>";
print "<td>" . $row["name"] . "</td>";
print "<td>" . $row["type"] . "</td>";
print "<td>" . $row["description"] . "</td>";
print "<td>" . $row["quantity"] . "</td>";
print "<td>£" . $row["price"]. "</td>";
print "<td>" . $row["Image"]. "</td>";
print "<td> <a href='cart.php?action=add&id=" .$row['productid']. "'>Add to cart</a></td>"; ;
print "</tr>";
}
print "</table>"
 
don't put the image in the database. Just save the image somewhere else on your document path, and then reference that in the database. So all you store in the database would be something like:
'/images/great_pic.jpg'
and use that string as a url reference on your page.
 
Back
Top