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
Create a Relationship Example
Consider the following tables (and SQL insert statements):
CREATE TABLE tblGenres(
pkGenreID INT PRIMARY KEY AUTO_INCREMENT,
fldGenre VARCHAR(40)
);
CREATE TABLE tblMyMp3CollectionDemo2(
pkMP3ID INT PRIMARY KEY AUTO_INCREMENT,
fldFilename VARCHAR(150),
fldTitle VARCHAR(60),
fldArtist VARCHAR(60),
fkGenreID INT
);
INSERT INTO tblGenres (fldGenre) VALUES ("Rock");
INSERT INTO tblGenres (fldGenre) VALUES ("Pop");
INSERT INTO tblGenres (fldGenre) VALUES ("Euro Trash");
INSERT INTO tblGenres (fldGenre) VALUES ("Sweedish HipHop");
| fldFilename | fldTitle | fldArtist | fkGenreID | Action |
|---|---|---|---|---|
| iuiui | iuiu | iuiu | 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", "tblMyMp3CollectionDemo2", "pkMP3ID");
$tblDemo->defineRelationship("fkGenreID", "tblGenres", "pkGenreID",
"fldGenre");
$tblDemo->omitPrimaryKey();
#actually show to the table
$tblDemo->showTable();
View Example by Itself
Click here to view example outside of the template.
Recent Feedback
"Looks efficient. I`m going to go try it out..." - Posted by Jason R on Friday Jul 11th, 2008 at 4:32pm
"Just perfect ..." - Posted by Besmir S on Thursday Jul 17th, 2008 at 7:51pm
"Perfect. I`m go try it
Amigo" - Posted by Horacio from méxico on Tuesday Aug 12th, 2008 at 3:23pm
Amigo" - Posted by Horacio from méxico on Tuesday Aug 12th, 2008 at 3:23pm
"comment3, " - Posted by jonn2 on Saturday Nov 8th, 2008 at 12:22am
"its so cool...." - Posted by martin on Friday Mar 13th, 2009 at 4:27pm
"This is a very useful tool!!!
Are you still working on it?" - Posted by Omar on Monday May 11th, 2009 at 1:03am
Are you still working on it?" - Posted by Omar on Monday May 11th, 2009 at 1:03am
"Sweet!!! One of the few packages that runs right out of the box. Just modify a couple of lines database.php, it runs perfectly. Can`t wait to look at the code." - Posted by Mike on Thursday Jun 4th, 2009 at 9:27pm
"Excellent!! Very Nice and simple!" - Posted by Bahassine on Monday Oct 5th, 2009 at 12:49pm
"Is there a way to define two or Join more than 2 tables?" - Posted by Roger on Sunday Nov 29th, 2009 at 11:17pm
"There are bug in IE." - Posted by Ali on Friday Dec 4th, 2009 at 3:15am
Leave a Comment
"Very interesting class. Thanks a lot."
~gustavo
