Storing and displaying PDF in MySQL and PHP

Hello, everybody!

Here's what I want to achieve:
In a table of a DB mysql, I would have 2 fields: a text box (a title) and a
field capable of storing the contents of a pdf.
I want to add (delete, modify) records. When I add a new record, I want to
type the title and the path and name of a pdf file. The content of this file
should be stored pdf in the scope of the table.
In visualization, I want to get a list with titles and next to each title a
button to display the contents of the pdf field in Acrobat Reader.

My questions are:
-- What kind of field use in the table to receive the contents of pdf ?
-- How to send the contents of pdf in the field?
-- How to display the contents of the field in acrobat reader?

It's certainly very basic but I started in php and mysql. Be indulgent ... A
small piece of code would help me greatly, I thank you in advance.

Marc.
Merou63 [ Mo, 31 März 2008 16:16 ] [ ID #1931701 ]

Re: Storing and displaying PDF in MySQL and PHP

Merou63 wrote:
> Hello, everybody!
>
> Here's what I want to achieve:
> In a table of a DB mysql, I would have 2 fields: a text box (a title) and a
> field capable of storing the contents of a pdf.
> I want to add (delete, modify) records. When I add a new record, I want to
> type the title and the path and name of a pdf file. The content of this file
> should be stored pdf in the scope of the table.
> In visualization, I want to get a list with titles and next to each title a
> button to display the contents of the pdf field in Acrobat Reader.
>
> My questions are:
> -- What kind of field use in the table to receive the contents of pdf ?
> -- How to send the contents of pdf in the field?
> -- How to display the contents of the field in acrobat reader?
>
> It's certainly very basic but I started in php and mysql. Be indulgent ... A
> small piece of code would help me greatly, I thank you in advance.
>
> Marc.
>
>
>

What kind of column to use is a database question, and should be asked
in a newsgroup related to your database - in this case
comp.databases.mysql. Hint: you'll need a column big enough to store
the data, and since a PDF is binary data, the column needs to be a
binary type.

From the PHP end, adding, updating and deleting rows is pretty
straightforward. The fact you have a PDF vs. other data only makes a
minor difference - you'll need to read the PDF into a variable (check
out fopen(), fread() and fclose()) then store it in the table.

For this and retrieving the data you'll need some fairly basic SQL. But
all of it is a bit much for a few newsgroup postings. I'd recommend you
search for some basic tutorials on PHP and MySQL. There are some good
ones out there which can help you (but sorry, right now I don't have any
pointers).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex [at] attglobal.net
==================
Jerry Stuckle [ Mo, 31 März 2008 19:13 ] [ ID #1931703 ]

Re: Storing and displaying PDF in MySQL and PHP

On Mon, 31 Mar 2008 16:16:51 +0200, "Merou63" <merou63 [at] hotmail.com>
wrote:

>Hello, everybody!
>
>Here's what I want to achieve:
>In a table of a DB mysql, I would have 2 fields: a text box (a title) and a
>field capable of storing the contents of a pdf.
>I want to add (delete, modify) records. When I add a new record, I want to
>type the title and the path and name of a pdf file. The content of this file
>should be stored pdf in the scope of the table.
>In visualization, I want to get a list with titles and next to each title a
>button to display the contents of the pdf field in Acrobat Reader.
>
>My questions are:
>-- What kind of field use in the table to receive the contents of pdf ?
>-- How to send the contents of pdf in the field?
>-- How to display the contents of the field in acrobat reader?
>
>It's certainly very basic but I started in php and mysql. Be indulgent ... A
>small piece of code would help me greatly, I thank you in advance.
>
>Marc.
>

why don't you store, in the second field (varchar), a link to the pdf
that you want to dsiplay instead of storing the pdf itself?
it will save you a lot of space in the table and then if you decide to
modify the pdf you don't have to modify the table.
NN
nn [ Mo, 31 März 2008 17:44 ] [ ID #1933012 ]

Re: Storing and displaying PDF in MySQL and PHP

Thank you very much for your help.

Marc.


"Merou63" <merou63 [at] hotmail.com> a écrit dans le message de
news:fsqm2o$fml$1 [at] news.brutele.be...
> Hello, everybody!
>
> Here's what I want to achieve:
> In a table of a DB mysql, I would have 2 fields: a text box (a title) and
a
> field capable of storing the contents of a pdf.
> I want to add (delete, modify) records. When I add a new record, I want to
> type the title and the path and name of a pdf file. The content of this
file
> should be stored pdf in the scope of the table.
> In visualization, I want to get a list with titles and next to each title
a
> button to display the contents of the pdf field in Acrobat Reader.
>
> My questions are:
> -- What kind of field use in the table to receive the contents of pdf ?
> -- How to send the contents of pdf in the field?
> -- How to display the contents of the field in acrobat reader?
>
> It's certainly very basic but I started in php and mysql. Be indulgent ...
A
> small piece of code would help me greatly, I thank you in advance.
>
> Marc.
>
>
Merou63 [ Mi, 02 April 2008 15:23 ] [ ID #1933981 ]
PHP » alt.php » Storing and displaying PDF in MySQL and PHP

Vorheriges Thema: mass manipulation within a CSV file
Nächstes Thema: I have problem with UTF-8 in mysql