ajaxCRUD.com
» a PHP API to create / read / update / delete from a database table using AJAX
by loud canvas mediaQuick Links:
Quick Examples:
- Creating a Relationship
- File Uploading
- Using a Where Clause
- Defining Allowable Input
- Formatting Fields With Function
www.allthewebsites.org
File Upload Example
Consider the following table:
CREATE TABLE tblMyMp3CollectionDemo( pkMP3ID INT PRIMARY KEY AUTO_INCREMENT, fldFilename VARCHAR(150), fldTitle VARCHAR(60), fldArtist VARCHAR(60), fldGenre VARCHAR(40) );
| fldFilename | fldTitle | fldArtist | fldGenre | Action |
|---|---|---|---|---|
| Add File | asd | asdasd | Pop | |
| Add File | Pop | |||
| Add File | Rock | |||
| Add File | 2 | 3 | Rock | |
| Add File | Blues | |||
| Add File | Rock | |||
| Add File | tt | tt | Rock | |
| Add File | TitleS | Britney Tops | Rock | |
| Add File | Rock | |||
| Add File | aaa | zzz | Country | |
| Add File | Rock | |||
| Add File | sss | sss | Euro Pop | |
| Add File | Rock | |||
| Add File | fdgfd | fdgfdgf | Euro Pop | |
| dd (edit delete) | dd | d | Country | |
| sdfdsf (edit delete) | sdf | sdfsdf | Country | |
| Add File | title | artist | Rock | |
| gdsfg (edit delete) | sdfg | sdfg | Rock | |
| Add File | Country | |||
| Add File | Blues | |||
| asdfasdf (edit delete) | asdfasdf | asdfasdf | Rock | |
| teste (edit delete) | tset | tsets | Rock | |
| Add File | Country | |||
| folky.mp3 (edit delete) | folky | charrito | Country | |
| folky.mp3 (edit delete) | folky | charrito | Country | |
| poppy.mp3 (edit delete) | sdffffffffffffffffffffffffffffffffffffffffffffffffff | gsdfgsdfgsdfgsdfgsdfg | Pop |
Class Implementation:
#include the class
include ('ajaxCRUD.class.php');
#this one line of code is how you implement the class
$tblDemo = new ajaxCRUD("MP3 File",
"tblMyMp3CollectionDemo", "pkMP3ID");
$tblDemo->omitPrimaryKey();
$tblDemo->setFileUpload("fldFilename", "uploads/");
$allowable_vals = array("Rock", "Euro Pop", "Trance", "HipHop");
$tblDemo->defineAllowableValues("fldGenre", $allowable_vals);
#actually show to the table
$tblDemo->showTable();
View Example by Itself
Click here to view example outside of the template.
Recent Feedback
"OMG! This is just what I was looking for. Thanks so much. This is amazing!" - Posted by Simone on Friday Jul 11th, 2008 at 4:34pm
"Sorry all -- had to disable uploading due to hacking attempts. Feel free to try out on your own server though!" - Posted by Sean Dempsey on Sunday Sep 14th, 2008 at 7:23pm
"comment2, " - Posted by jonn2 on Sunday Nov 9th, 2008 at 6:21am
"awesome it is best
working fine
thanks" - Posted by fakhru on Tuesday Dec 16th, 2008 at 5:28am
working fine
thanks" - Posted by fakhru on Tuesday Dec 16th, 2008 at 5:28am
"ajaxCRUD.class.php on line 1238" - Posted by Juan Carlos on Monday Jan 19th, 2009 at 4:32pm
"just what i looked for..." - Posted by Sergey on Wednesday Mar 25th, 2009 at 11:02am
"I can`t wait to give this a try." - Posted by Fortin on Thursday Mar 26th, 2009 at 3:58pm
"I can`t wait to give this a try." - Posted by Fortin on Thursday Mar 26th, 2009 at 3:59pm
Leave a Comment
"I love AjaxCRUD! It's saved me hours upon hours of typing!"
~Eric Duwenhoegger
"AjaxCRUD is wonderful."
~Peter Barone
