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
Show Checkbox - All
Consider the following table:
CREATE TABLE tblDemo( pkID INT PRIMARY KEY AUTO_INCREMENT, fldField1 VARCHAR(45), fldField2 VARCHAR(45), fldCertainFields VARCHAR(40), fldLongField TEXT );
| fldField1 | fldField2 | fldCertainFields | fldLongField |
|---|---|---|---|
| Dropdown Value | -- | ||
| Dropdown Value | -- | ||
| Dropdown Value | jhzttt |
Class Implementation:
#include the class
include ('ajaxCRUD.class.php');
#this one line of code is how you implement the class
$tblDemo = new ajaxCRUD("Item", "tblDemo", "pkID");
$tblDemo->omitPrimaryKey();
#define our checkboxes
$tblDemo->defineCheckbox('fldField1','on','off');
$tblDemo->defineCheckbox('fldField2','on','off');
#show header checkboxes
$tblDemo->showCheckboxAll('fldField1', true);
$tblDemo->showCheckboxAll('fldField2', true);
#for heck of it, only certain fields are allowed for fldCertainFields
$allowableValues = array("Allowable Value 1", "Allowable Value2",
"Dropdown Value", "CRUD");
$tblDemo->defineAllowableValues("fldCertainFields", $allowableValues);
#disallow adding and deleting rows
$tblDemo->disallowDelete();
$tblDemo->disallowAdd();
#actually show the table
$tblDemo->showTable();
Read API Documentation on this function here.
View Example by Itself
Click here to view example outside of the template.
"...first of all great work! :) Really smooth operation and deployment."
~Jonathan
