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


Need Your Help

Which part of the CAP theorem does Cassandra sacrifice and why?

cassandra partitioning high-availability consistency cap-theorem

There is a great talk here about simulating partition issues in Cassandra with Kingsby's Jesper library.

MySQL insert - for each row, return insert id

mysql cursor bulkinsert last-insert-id

Let's say I have an array of data to insert. I'm going to have an insert that looks like this: