ajaxCRUD.com
» a PHP class to Create, Read, Update, & Delete from a mysql database table using AJAX
by loud canvas mediaQuick Links:
Quick Examples:
- Displaying Images
- Creating a Relationship
- File Uploading
- Using a Where Clause
- Defining Allowable Input
- Formatting a Field With a Function
- Vertical Display
- Show Header Checkbox
- Modify Field with Class
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 |
|---|---|---|---|---|
| 5 (edit delete) | 5 | 5 | Pop | |
| 4 (edit delete) | 5 | 6 | Rock | |
| Add File | -- | -- | Rock | |
| Add File | 777 | 77 | Rock | |
| Add File | -- | -- | Rock | |
| Add File | -- | -- | -- | |
| Add File | -- | -- | Rock | |
| Add File | -- | -- | Rock | |
| hgff (edit delete) | ttsss | test | Rock | |
| Add File | wv | ssd | Rock | |
| Add File | -- | -- | Rock | |
| mnvmv (edit delete) | hgfd | fhjfj | Pop | |
| Add File | -- | -- | Rock | |
| Add File | df dfgdfg | d fgdf gdf | Country | |
| Add File | ewe | qweqweq | HipHop | |
| Add File | -- | -- | Rock | |
| Add File | -- | -- | Country | |
| Add File | llk | 4234234 | Rock | |
| Add File | Nmkkn | Nmnnjk | Country | |
| Add File | -- | -- | Rock | |
| ` (edit delete) | ` | ` | Rock | |
| Add File | -- | -- | Rock | |
| Add File | -- | -- | Rock |
Class Implementation:
#required file and class
require_once ('preheader.php');
include_once ('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
"Great Stuff !!
You Are Wonderful People
Thanks" - Posted by Mark on Wednesday Oct 27th, 2010 at 10:23am
You Are Wonderful People
Thanks" - Posted by Mark on Wednesday Oct 27th, 2010 at 10:23am
"There is a bug in the fileupload() when you try to upload big size file it just don`t upload and throw error " There was an error uploading your file (or none was selected)."...
Guy`s any one face the same error like i faced
--Alex" - Posted by Alex on Monday Aug 1st, 2011 at 12:53pm
Guy`s any one face the same error like i faced
--Alex" - Posted by Alex on Monday Aug 1st, 2011 at 12:53pm
Leave a Comment
"Thanks for the great script, you rock big time."
~Daniel
