473,414 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

php blob - display in html table

Hi, I have an issue that i just cant seem to figure out hope some one
can help.

right i am getting people to input the own images directly into a blob
within a mysql database. then on the next page i want to display the
image with in a nicely formatted html table so i can put the image
where i choose on the page

*this code is only putting the image on the top of the page and wont
let me output any other text etc*

here is the code to display the blog image file-
<?php

$id;

// you may have to modify login information for your database
server:
@MYSQL_CONNECT("localhost","root","admin");

@mysql_select_db("tablename");

$query = "select bin_data from binary_data where id=$id";
$result = @MYSQL_QUERY($query);

$data = @MYSQL_RESULT($result,"bin_data");

echo $data;
?>
<html>
<head>
<title>Untitled</title>
</head>

<body>

</body>
</html>
Please i am most grateful to any one that can help best regards adam
Jul 17 '05 #1
3 10415
adam wrote:
Hi, I have an issue that i just cant seem to figure out hope some one
can help.

right i am getting people to input the own images directly into a blob
within a mysql database. then on the next page i want to display the
image with in a nicely formatted html table so i can put the image
where i choose on the page

*this code is only putting the image on the top of the page and wont
let me output any other text etc*
This is more or less pure luck. Some browsers defaults to showing plain
text when the content of the response is undefined.

There was a thread a while ago, on how to mix html and binary imagedata.
But I would not recommend it for ordinary web-use.

Stick to having a specific content-type for each webrequest.

here is the code to display the blog image file-
<?php

$id;
Dont require register_globals
$id = $_GET['id']

// you may have to modify login information for your database
server:
@MYSQL_CONNECT("localhost","root","admin");

@mysql_select_db("tablename");
? dbname
$query = "select bin_data from binary_data where id=$id";
$result = @MYSQL_QUERY($query);

$data = @MYSQL_RESULT($result,"bin_data");
//you may want to store the image type with the imagedata
Header("Content-Type: image/jpeg");
echo $data;
//end request
exit;

?>

[snip]

/Bent
Jul 17 '05 #2
thanks so far...

but what is the code i need to use to be able to display both html and
the blob in an html table this is wot i need urgently i have been
trying for hours with out success. thanks people
Jul 17 '05 #3
.oO(adam)
thanks so far...

but what is the code i need to use to be able to display both html and
the blob in an html table this is wot i need urgently i have been
trying for hours with out success. thanks people


Usually you need two scripts: One for delivering the HTML, another for
the binary stuff, because the browser has to request two resources from
the server. The HTML then contains an img-element with a link to the
second script, which delivers the image with the correct content-type
header:

<img src="yourImageScript.php" alt="...">

It's also possible to embed binary data in a HTML document with using
the data scheme, but that's not supported by all browsers, e.g.

<img src="data:image/jpeg;base64,base64-encoded data follows" alt="...">

RFC 2397 - The "data" URL scheme
http://www.faqs.org/rfcs/rfc2397.html

Micha
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Big Red | last post by:
Hi all I am reasonably new at php. I have a database table with three fields, id, caption and data. I have used the id and caption to create a dynamic menu. it just throws it into a loop with...
7
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and...
2
by: Carolyn Longfoot | last post by:
Help! This is driving me crazy... I'm trying to read a BLOB from a db and display it in a browser, like so: $query="SELECT blob from table where blob_id=9"; $result=mysql_query($query);...
15
by: Daniel Schuchardt | last post by:
Hi @ all, i'm sure there was a psql-function to transfere my Blob-Data to the server but I can't remember. I have a script like this : UPDATE xy SET z = lo_import('localpath_and_file'); ...
3
by: Stanley Sinclair | last post by:
(Minor question. Since updating to FP4 I cannot access HTML help. Compiler error. What's wrong?) _______________________ Subject of this message: There is lots of Help regarding getting...
3
by: Carmine | last post by:
I have to add a date column to a db2/zos table with a blob column. Can I rename the blob table to old, create a new table with the date column, then insert/select the data from the old table? ...
1
by: bimeldip | last post by:
Hi, I've been dabbling with mysql php and xml... I have managed to learn how to upload xml file into mysql datbase and download the file from mysql database to display the content on the file....
11
by: nse111 | last post by:
<?php //header('Content-Type: image/jpeg'); header('Content-Type: text/html'); @mysql_connect("localhost","root","dba") or die("Error"); @mysql_select_db("gallery"); $result =...
2
by: wizardry | last post by:
hello - i'm trying to insert a blob into my table, it will insert but the string that i insert when i query the inserted data returns null with 0 bytes in the column. I have other tables set...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.