ajaxCRUD.com

» a PHP class to Create, Read, Update, & Delete from a mysql database table using AJAX

   by loud canvas media

Quick Links:

Quick Examples:


Modify Field With Class


Consider the following table:


CREATE TABLE tblFriend (
pkFriendID int(11) PRIMARY KEY AUTO_INCREMENT,
fldName varchar(25),
fldAddress varchar(30),
fldCity varchar(20),
fldState char(2),
fldZip varchar(5),
fldPhone varchar(15),
fldEmail varchar(35),
fldDateMet date,
);


Name:
NamePhoneZipDate We MetAction
-- -- -- 0000-00-00
-- -- -- 2014-08-01
-- -- -- 0000-00-00
-- -- -- 0000-00-00
-- -- -- 0000-00-00
-- -- -- 0000-00-00
-- -- -- 0000-00-00
-- -- -- 0000-00-00
-- -- -- 0000-00-00
-- (235) 555-2522 23666 0000-00-00

1 2      >> >>|



Class Implementation:


---your class.php---

#required file and class
require_once ('preheader.php');
include_once ('ajaxCRUD.class.php')

#create an instance of the class
$tblFriend = new ajaxCRUD("Friend", "tblFriend", "pkFriendID");

//if we only want to show a few of the fields in the table
$tblFriend->showOnly("fldName, fldPhone, fldZip, fldDateMet");

#set the number of rows to display (per page)
$tblFriend->setLimit(10);

#set a filter box at the top of the table
$tblFriend->addAjaxFilterBox('fldName', 20);

#modify field with class
#for masking and for adding calendar widget
$tblFriend->modifyFieldWithClass("fldDateMet", "datepicker");
$tblFriend->modifyFieldWithClass("fldZip", "zip");
$tblFriend->modifyFieldWithClass("fldPhone", "phone");

#show CSV export button
$tblFriend->showCSVExportOption();

#order the table by any field you want
$tblFriend->addOrderBy("ORDER BY fldName");

$tblFriend->showTable();


---validation.js---

// mask some fields with desired input mask
$("input.phone").mask("(999) 999-9999");
$("input.zip").mask("99999");

//put a date picker on a field
$( ".datepicker" ).datepicker({
	dateFormat: 'yy-mm-dd',
	showOn: "button",
		buttonImage: "includes/images/calendar.gif",
		buttonImageOnly: true,
	onClose: function(){
		this.focus();
		//$(this).submit();
	}
});

View Example by Itself

Click here to view example outside of the template.

 

"just what i [was] look[ing] for..."
~Sergey

What is a business/commercial website?

A commercial website is one created for a business, for which purpose is generating revenue or cash flow of any type (and that isn't under a non-profit organization). So if you're selling a product, selling advertisement, selling a service, or just marketing a commercial business, your site is commercial. A company website is also commercial even if it doesn't sell anything, as it's purpose is to front a commercial company.
Close