Jump to content

Echo images and substr from single field in database into html divs


andy11

Recommended Posts

I've been trying to echo images from a database into both an html table (in rows of five) and into a div for many days. I will come back to the table later but I could use some help with the divs. It was easy to echo out the fields as shown but the actual image, well not yet. The commented out echoes are the problem. It needs to have both the image and the substr (0, -4) load into a single div. I also need to set a specific width to force proportional sizing and I'm sure that get's added to the echoed image tag. Can someone help?

 

Here is my code;

 

<?php

require ("connection.php");

$result = "SELECT * FROM products";

$product_query = mysql_query($result);

$product_count = mysql_num_rows($product_query);

 

while($row = mysql_fetch_array( $product_query )) {

 

$src = $product['product'];

$name =  substr($product, 0, -4);

 

echo "<div id=\"image\">";

echo $row['product'];

//echo "<img src='$src' alt='' />";

echo "<div id=\"name\">";

echo $row['catagories'];

//echo $name;

echo "</div></div>";

echo "<br/>";

}

 

 

?>

 

Thank you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.