Robert Hazeltine wrote:
> I am working on a project whereby all the relevant data is stored in the
> Mysql database and then when required the data is compiled into
> a web page.
> I have all the text data working properly, but cannot figure out how
> to display the image BLOBS I have created at the same time, or
> being able to format them within the appropriate HTML tags.
> I was hoping I could do something similar to (pseudo-code):
> # get the image from the database
> $image = "select image from table where id = foo";
> # display the image in HTML
> <IMG SRC = "$image">
> I tried many different ways of getting to this, but none of them
> work. I found an example in a news archive somewhere that lets
> me display the BLOB direct from the database, but it requires that
> I pass a lot of the information about the file (content/type &c)
> myself and it does not let me do any proper formatting on the images
> layout and nor can I display text in the browser at the same time.
> Given that I have my image BLOB properly accessible in the database,
> and I can already pop out any arbitrary text as I wish, what do I
> do next for images?
You can be sure that BLOB will work properly ( as long as your read()/
write() calls do fail :) )
I will answer with an example that should clear things up.
printf("<img src=shoot_gif?pict_id=%d>", pict_id);
gif_data = get_gif_from_db(&gif_size);
write(1, gif_data, gif_size);
if this is unclear, e-mail me, and I'll answer in more detail.