|
||||||
| PHP Tutorials PHP Tutorials |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
Okay..I'm going to show y'all how to show your images.. those which are in your DB
It's very very simple.. so..First of all we must connect to our database PHP Code:
$password = ""; - It's your database's password $host = "localhost"; - It's your database's host, usually it's localhost but it can be something else also $database = ""; - It's your database Now let's connect to the database PHP Code:
@mysql_select_db($database) or die("Can not select the database: ".mysql_error()); - This will select your database Now let's get our id PHP Code:
So.. your id will be 3 and it will show an image which id is 3 PHP Code:
die("Please select your image!"); - lets display an error }else{ - But if it is set let's continue with showing our image ![]() PHP Code:
$row = mysql_fetch_array($query); - Let's gather our info about image which id is $id into one variable $content = $row['image']; - Get's the blob from our table Now let's display our image PHP Code:
echo $content; - This will display our blob.. } - Ends else Okay.. now here's our full script. PHP Code:
![]() ![]() Enjoy ![]() If you have questions then please feel free to ask ![]()
__________________
Last edited by Jordan; 05-07-2008 at 12:02 PM. |
| Sponsored Links |
|
|
|
|||||
|
If `id` is always to be an integer, it would be wise to add:
PHP Code:
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||
|
Jaan,
I loved your easy to follow instructions but I want to do something slightly different. I have a MySQL db and want to display a Blob image from it into a table populated by PHP. I have a MySQL query which selects all records from the database and then displays the text content from each record on a row in the table. I want one of the table cells in each row to display the blob image. How do I do this? Regards CG |
| Sponsored Links |
|
|
|
|||||
|
I believe.. then you should create a real images from those blobs.. use this tutorial to create those images:
Create files with php there.. this blob will be this $content.. so replace it.. and then.. after your script ends.. just delete those images.. then just use PHP Code:
PHP Code:
![]() i believe it works
__________________
|
|
|||||
|
Well, great tutorial. +rep
__________________
Free Web Templates like WebSpell, FrontPage and more. |
|
|||
|
Hi everybody, sorry with my english... this is my first post here....
i hav a question ¿how ill show all images from my DDBB where i hav user ID? this tutorial show just 1 images ....but if i hav a lot of picture and i need to show all of the USER ID x? im trying to do a while but i cant do this work Some Help? Thanks |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tutorial: Storing Images in MySQL with PHP | Jordan | PHP Tutorials | 10 | 06-22-2008 07:02 PM |
| Tutorial: PHP to MySQL | Jordan | PHP Tutorials | 5 | 04-22-2008 09:15 AM |