473,788 Members | 3,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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","ro ot","admin");

@mysql_select_d b("tablename" );

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

$data = @MYSQL_RESULT($ result,"bin_dat a");

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 10458
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_global s
$id = $_GET['id']

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

@mysql_select_d b("tablename" );
? dbname
$query = "select bin_data from binary_data where id=$id";
$result = @MYSQL_QUERY($q uery);

$data = @MYSQL_RESULT($ result,"bin_dat a");
//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="yourImageS cript.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,bas e64-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
2194
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 extra html formatting stuff. No problem. The data field is a large blob. The data is a complete html file which comes out of a timing system for race cars, its basically a big table.
7
7100
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 disadvantages of using a MySQL blob field rather than reading the images directly from the file? How does one insert an image into a blob field? Can it be done dynamically? Thank you John
2
6122
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); $blob=mysql_fetch_assoc($result); Now when I do print_r (array_values($blob));
15
12351
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'); but i want to execute this script from the client and so my blob-data is
3
11512
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 data out of BLOB and CLOB storage, but I see little on getting data into it. I know it's there, but could someone speed my search? A colleague created the following table:
3
7311
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? Do I have to select data from the main table and the aux table or is the aux table done automatically? What's the best way to handle this?
1
2722
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. However the What i would like to know is how do i manipulate the php codes to display the content on the file in a proper form?... So far i have done this: <? if(isset($_GET)) { include 'config.php';
11
10824
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 = mysql_query("SELECT * FROM paintings"); while($row = mysql_fetch_assoc($result)){ print $row."</br>"; //print $row; }
2
5052
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 up this way and i'm able to insert text data into it with no problems. I've checked the database design its basiclly a duplicate. I did have to remove my not null on the long blob element. but other then that, i don't understand why this is...
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.