[amazonify]032152599X:left[/amazonify]
As our data getting mobile and copying picture is annoying for me I decide to save the picture in the database (mysql).
Another challenge came when other division need the data exported in a directory with same dimension (135 x 180 pixel).
Structure for table ’student_pic’ :
CREATE TABLE `student_pic` (
`image_id` int(10) unsigned NOT NULL auto_increment,
`username` varchar(50) NOT NULL default ”,
`image_type` varchar(50) NOT NULL default ”,
`image` longblob NOT NULL,
`image_size` bigint(20) NOT NULL default ‘0′,
`image_name` varchar(255) NOT NULL default ”,
`image_date` datetime NOT NULL default ‘0000-00-00 00:00:00′,
UNIQUE KEY `image_id` (`image_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3385 ;
Yes, I use mysql 5 ( 5.0.45)
After googling for while and read php manual I use this script to export data from database :
$db = mysql_connect(”localhost”, “root”,”alam”) or die(mysql_error());
mysql_select_db(”education”,$db) or die(mysql_error());
$username_student=’wahyu’;
$sql = “SELECT * FROM student_pic WHERE username=’$username_student’”;
$result = mysql_query ($sql);
if (mysql_num_rows ($result)>0) {
$row = mysql_fetch_array ($result);
$image_type = $row[”image_type”];
$image = $row[”image”];
Header (”Content-type: $image_type”);
$file = fopen(”c:/appserv/www/$username_student.jpg”,”w”);
fwrite($file, $image);
}
explanation of this script :
$db = mysql_connect(”localhost”, “root”,”alam”) or die(mysql_error());
connect to database, its host = localhost, user = root and password = alam
mysql_select_db(”education”,$db) or die(mysql_error());
select database to connect, in this case connect to ‘education’
$username_student=’wahyu’;
pick sample user before looping for 3385 entry
$sql = “SELECT * FROM student_pic WHERE username=’$username_student’”;
$result = mysql_query ($sql);
take data from table student_pic for user ( in this case I use wahyu)
if (mysql_num_rows ($result)>0) {
action …..
}
if query return a result then script executed.
$row = mysql_fetch_array ($result);
fetch data with mysql_fetch_array
$image_type = $row[”image_type”];
put variable $image_type for Header purpose
$image = $row[”image”];
put variable $image for gettting blob data in table
Header (”Content-type: $image_type”);
Header, tell browser about data type.
$file = fopen(”c:/appserv/www/$username_student.jpg”,”w”);
open file handler, since I use appserv I use c:/appserv/www as absolute path
fwrite($file, $image);
save the file.
Thic snippet will export picture from database to a file in directory www. Not resizing the dimension.
I already try to resize it with php but I still not satisfied with the result. Thats why I use software to do that job
I use image resizer software ImRe 2.1 from Vicky Software.

Yes, as you see. This software use simple gui and it’s freeware too
Hope this help someone that looking for way to export data from mysql database to a file and resize the pictures.
- export images from mysql
- export image from mysql
- export image from mysql db
- mysql export longblob
- mysql export image
- mysql export picture
- export image from mysql database
- php mysql blob photo gallery
- mysql picture database
- export pictures from mysql
- export images from sql database
- export mysql images
- export images out of mysql table
- resize image in database
- picture database
- export mysql image
- export picture
- picture with mysql
- how to put a picture from mysql database to my web
- how to export picture from database
- mysql export pictures
- php blob jpeg mysql resize
- mysql export images
- mysql export images from database
- mysql image database
- export data from mysql script images
- video tutorial storing image to mysql
- mysql image resize
- php mysql export images to files
- php export mysql to insert in jpeg file
- php Header (Content-type: $image_type);
- php image from database to file export
- mysql export photos to resize
- php image from mysql to file
- mysql export longblob files
- php mysql longblob picture select
- php mysql image upload export
- php mysql image export
- php mysql export picture
- php image mysql resize
- mysql isam table resize
- php export images from mysql
- mysql image exportes
- mysql migrate database images
- mysql picture
- mysql image export
- save picture mysql
- mysql picture field
- MySQL image
- mysql table script image
thx, great tutorial