Jump to content

DISPLAYING an image from MySQL database into HTML table.


DarnStuckAgain

Recommended Posts

Not really sure how to get the images I have stored in MySQL into a html form. I can call-up the text fields from the database but it cannot seem to find the index for the images.

 

Here is my code:-

 

<?php

session_start();

mysql_connect("localhost","root","abc") or die ("Error! Cannot connect to database");

mysql_select_db("theimageworks") or die ("Cannot find database");

$query = "SELECT * FROM jobs";

$result = mysql_query($query) or die (mysql_error());

?>

 

 

<?php

//display data in html table

echo "<table>";

echo "<tr><td>Username</td><td align='center'>Message</td><td>Product Image</td></tr>";

 

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

echo "</td><td>";

echo $row['username'];

echo "</td><td>";

echo $row['message'];

echo "</td></tr>";

echo $row['image'];

    }

echo "</table>";

?>

 

The error message I get is "Notice: Undefined index: image in....."

 

Thanks in advance!

Link to comment
Share on other sites

Yes I am storing images in a database for learning purposes (I know it's not recommended).

 

You were right I wrote the wrong table name sorry about that -.-

 

The code is changed to this now :-

 

echo "<img src='".$row['jobimage']."'>";

 

but I am getting a huge screen filled with random symbols like "HªG<Œ€:”®ì[vW¬¬e•™L¡K»Ô⩾y$M¹Q›owuŒ›Ir"

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.