Jump to content
Larry Ullman's Book Forums

Recommended Posts

You can store a file in the database using the BLOB data type. You can reveal it using a proxy script. Printing isn't a PHP issue.

 

and i just save the picture after i load it? if PHP can not print the data, so...what PHP used for? thanks for the answer Larry

Link to comment
Share on other sites

I think by

 

Printing isn't a PHP issue.

 

Larry was talking about if you want to print the image off on paper then it's not a PHP issue. You still need to use PHP to query the database and to store the image.

 

To store the important part is to convert to binary format which basically means using:

 

file_get_contents();

 

To display it you can use something like:

 

echo '<img src="data:image/png;base64,' . $row['image'] . '">';

Link to comment
Share on other sites

guys...thanks for all the answer...honestly, i'm real newbie. all larry code in his book, i can follow and works, great! but some thing came up into my mind...example i have employee data with picture. i save the data, and when i click the next button or number(pagination), the next data of employe with picture shows(just imagination/i don't know how yet). maybe and just maybe i can understand what stuart said bout how to save and reveal picture, thanks. but how can i print all the employee data to papers?

 

and one more(just came up into my mind...) can PHP do like this...example we have employee aplication in our site, and each users can create their own database with the name they desire. so, 1 application, used by many users with many databases with different name. and we serve them create database button and load button when they have createa database. sorry toooo long...thanks

Link to comment
Share on other sites

Printing is a feature of the browser (i.e., it's a client-side thing). PHP does not apply to that concept because PHP is server-side. So you can use PHP to create a dynamic Web page, but then the user goes ahead and prints the page using their browser (you can use JavaScript for a shortcut to the print menu selection).

 

As for your second example, yes, PHP can do that. I'm not sure you'd want to, though.

Link to comment
Share on other sites

winPHP, most likely, you wouldn't need more than one database per application. Also, you wouldn't want users creating their own databases. Depending on exactly what you want to do, we could discuss the details in a separate post.

 

As for the image, Stuart is right, but I think starting off with a simpler example would be better. For example, let's imagine that we have two images in the following directory:

 

img/image1.jpg
img/image2.jpg

 

Normally, to display these via HTML, we'd use the following:

 

<img src="img/image1.jpg">
<img src="img/image2.jpg">

 

However, if we were to store the paths (i.e., img/image1.jpg and img/image2.jpg) in a database, we could use PHP to dynamically add images to the page, like the following:

 

echo '<img src="' . $image1 . '">'; // The path to image1.jpg has been pulled from a database table and is stored in $image1.
echo '<img src="' . $image2 . '">'; // The path to image2.jpg has been pulled from a database table and is stored in $image2.

 

Again, this is just a basic example, but hopefully you get the idea.

Link to comment
Share on other sites

 Share

×
×
  • Create New...