Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - Add rows to database based on images in folder -


this follows on question had earlier cleaning database can see here: remove row database if image not on server

i have mysql database table in following format:

id: 1
date: 2010-12-19
image: 5d61240f-7aca-d34b-19-12-10-15-36.jpg
caption: merry xmas

i want create php script checks through /gallery/ folder on server , every image in gallery folder isn't listed in database want create new row it's filename in image column. id sequential, date needs last modified date of file using filetime() , needs in yyyy-mm-dd format. caption column can blank these files we're adding. script appreciated.

thanks!

// list of allowed image extensions $image_exts=array('png','jpg','ico','gif','bmp'); // ...  // function store image file db function db_add_image($image){     $name=mysql_real_escape_string(basename($image));     mysql_query("insert `table` (`id`,`date`,`image`,`caption`)         values (null,'".date('y-m-d',filemtime($image))."','".$name."','')         not exists (select `id` `table` `image`='".$name."')"); }  // loop in folder (glob returns array of files matching wildcard) foreach(glob('gallery/*.*') $file)     // if file image...     if(in_array(strtolower(pathinfo($file,pathinfo_extension)),$image_exts))         // add image database         db_add_image($file); 

secure, clean, commented , ready shipping. that's $20 in all, please pay @ counter. :d

edit: 2 guys below, +1 both.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -