I want to add an image to my php script:

<?php

$sql = "select * from Prod_listing";
$result = mysql_query ($sql);

while ($row = mysql_fetch_array($result))
{
$field1= $row["Product_Name"];
$field2= $row["Product_Id"];
$field3= $row["Product_Description"];
$field4= $row["Product_picurl"];

echo "<h1> <strong> $field1 <br> </strong> </h1>"; // Header Tag, bold.tag
echo "$field2<br>";
echo "$field3<br>";
echo "$field4 <p>----------------<p>";
//echo
}
?>

The picture link is stored in $field4

thanks in advance

Recommended Answers

All 3 Replies

Firstly, you don't need to put a strong tag inside h1 since it already bolds anything in h1.
Secondly, an image link is created with <img src="image link here" alt="text to display if it doesn't show up" />

how do i use the data stored in $field4.

Since $field4 is storing the path of the image, as Shawncplus has already said, use <img src> tag.
ie.,
<img src="<?php echo $field4; ?>" alt="image" />

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.