Hi..

I want to simply upload a image to database..it may be the whole image or just the path or a html link of any image...and display it in another page..via a table...my main problem is I cant fetch & display it from database...I read and try some prevoius pages..but all in vain..plzz..give the full code...with database...

tanmoy_india>plzz..give the full code...with database...

Post your code and ask for the suggestion.

<table width="100%" border="0" >
  <tr>
    <td align="center" bgcolor="#E9013C" class="style6">Product_image</td>
    <td align="center" bgcolor="#E9013C" class="style3"><span class="style6">Technical Specs</span></td>
    <td align="center" bgcolor="#E9013C" class="style3"><span class="style6">Price</span></td>
    <td align="center" bgcolor="#E9013C" class="style3"><span class="style6">Link</span></td>
  </tr>
<?php 
$db_host='localhost';
$db_database='test';
$db_username='root';
$db_password='';
// Connect
$connection = mysql_connect($db_host, $db_username, $db_password);
if (!$connection){
die("Could not connect to the database: <br />". mysql_error( ));
}
// Select the database
$db_select = mysql_select_db($db_database);
if (!$db_select){
die ("Could not select the database: <br />". mysql_error( ));
}

$query = "SELECT * FROM product_database";


// Execute the query
$result = mysql_query($query);
if (!$result){
die ("Could not query the database: <br />". mysql_error( ));
}
// Fetch and display the results
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$product_image = $row["product_image"];
$techspecs = $row["techspecs"];
$price = $row["price"];
$link = $row["link"];
$url = $row["url"];
echo "<tr>";
echo "<td><center><big>$product_image</big></center></td>";
echo "<td><center><big>$techspecs</big></center></td>";
echo "<td><center><big>$price</big></center></td>";
echo "<td><center><big><a href=\"$url\">$link</a></big></center></td>";
echo "</tr>";
}
// Close the connection
mysql_close($connection);
?>
</table>

I want to display the image in the row named "product_image" by storing html image links like this "http://www.letsgomobile.org/images/news/nokia/nokia_n72.jpg" in the database...

If $product_image variable represent a path of image file then write following statement:

....
echo "<td><center><img src=\"$product_image\" /></center></td>";
....

thanks it works......

you just upload the image to the images folder on the remote site and store the full path into the database. Next time where you want to display the image just fetch the path from the database and put it into the IMG tag. It will work fine

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.