ajaxCRUD.com
» a PHP class to create / read / update / delete from a 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
- Show Header Checkbox
www.allthewebsites.org
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 );
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.
"OMG! This is just what I was looking for. Thanks so much. This is amazing!"
~Simone
