Jump to content

Trouble to output and resize both and text and image from database


BloodyBeginner

Recommended Posts

Hello!

 

I am rather new here, so please be patient  :-[

 

I have found a script on the internet that allows to upload text and images to table of a database and to output single images from the same table. He script consists of two files, one for the upload and one for the download/output. The one for the upload is working very well. I manage to upload one image at a time in combination with a description, title etc. successfully into the table of the DB and can see it there. So far so good.

 

The output with “getdata.php” is more tricky. Whatever I do, I only manage to output one single image in its original size at a time. I have tried to resize it, to place it into a table and to present text from the database in combination with the image but do not succeed. I can on the other hand present text only from the database without the image. But not both at the same time. After quite a few hours without success, I am now asking you for help.

 

My problems that I like to solve are:

 

1) How can I resize the image and present it in a table?

 

2) How can I at the same time and in the same table present text from the database (title, description etc)  in combination with the image.

 

Any help is very appreciated. I include the “getdata.php” and the table “binary_data” below.

 

Thank you very much and kind regards from Sweden!

 

/Felix

 

-------------------------

getdata.php

-------------------------

 

<?php

 

 

 

// getdata.php3 - by Florian Dittmer

 

// Example php script to demonstrate the direct passing of binary data

 

// to the user.

 

// Syntax: getdata.php3?id=<id>

 

 

 

if($id) {

 

 

 

 

include("../include/datalogin.php");

 

 

 

    @mysql_select_db("binary_data");

 

 

 

    $query = "select bin_data,filetype from binary_data where id=$id";

 

    $result = @MYSQL_QUERY($query);

 

 

 

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

 

    $type = @MYSQL_RESULT($result,0,"filetype");

 

 

 

    Header( "Content-type: $type");

 

echo "$data";

 

 

 

};

 

?>

 

 

-----------------------------

The table “binary_data”:

-------------------------

 

 

CREATE TABLE `binary_data` (

  `id` int(4) NOT NULL auto_increment,

  `myid` varchar(5) default NULL,

  `name` varchar(50) default NULL,

  `data1` text,

  `data2` text,

  `data3` text,

  `description` varchar(100) default NULL,

  `bin_data` longblob,

  `filename` varchar(50) default NULL,

  `filesize` varchar(50) default NULL,

  `filetype` varchar(50) default NULL,

  PRIMARY KEY  (`id`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

 

-----------------------------------

 

Archived

This topic is now archived and is closed to further replies.

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