How can i display image from mysql to table using php

Here is my code-

<?php
    $con = mysql_connect('db', 'table', 'p/w');
    if (!$con) {
        die('Could not connect: ' . mysql_error()); }
    mysql_select_db("db", $con);
    $result = mysql_query("SELECT * FROM computers WHERE KEYWORDS='Computers,Desktops'");
    echo "<table border='1' width='100%'  >";
    while($row = mysql_fetch_array($result)) {
        echo "<tr>";
        echo "<td>" . $row['NAME'] . "</td>";
        echo "<td>" . $row['MANUFACTURER'] . "</td>";

I want to display image from db stored as path here in one of the columns

echo "</tr>"; }
echo "</table>";
mysql_close($con);
?>

can anyone help? thanks

Answers


<?php 
$con = mysql_connect('db', 'table', 'p/w'); 
if (!$con) { die('Could not connect: ' . mysql_error()); } 
mysql_select_db("db", $con); 
$result = mysql_query("SELECT * FROM computers WHERE KEYWORDS='Computers,Desktops'"); 
echo "<table border='1' width='100%' >"; 
    while($row = mysql_fetch_array($result)) { 
        echo "<tr>";
        echo "<td>" . $row['NAME'] . "</td>"; 
        echo "<td>" . $row['MANUFACTURER'] . "</td>";
        echo "<td><img src='folder_name/".$row['image_name']."'></td>";
        echo "</tr>"; 
    }
echo "</table>";
mysql_close($con);
?>

folder_name=Name of the folder where image is saved image_name=field name of the image in your table name computers


You can use the img element wherever you want to show the image.

echo "<img src='" . $row['image'] . "'>". You can also check img element for HTML or img element for HTML5


Need Your Help

jQuery Ui theme - why should I pick it or shouldn't I?

jquery css jquery-ui theming

So my goal is to theme / create a new skin for an already existing application.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.