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:


Add Where Clause


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)
	);

Pop Songs

Filter Songs:
fldFilenamefldTitlefldArtistfldGenre
adsa asda adasd Pop
aad ada ada Pop

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();

#add the sql where clause
$tblDemo->addWhereClause("WHERE fldGenre = \"$genre\"");

$allowable_vals   = array("Pop", "Rock", "Country", "Blues");
$tblDemo->defineAllowableValues("fldGenre", $allowable_vals);

#don't allow deleting of rows
$tblDemo->disallowDelete();

?>

<h2><?php echo $genre?> Songs</h2>
<div style="float: right">
 Filter Songs:
 <form name="filterForm" id="filterForm" method="get" style="display: inline;" action="">
  <select name="genre" onchange="document.getElementById('filterForm').submit();">
  <option value="Pop" <? if ($genre == "Pop") echo "selected";?>>Pop Songs</option>
  <option value="Rock" <? if ($genre == "Rock") echo "selected";?>>Rock Songs</option>
  <option value="Country" <? if ($genre == "Country") echo "selected";?>>Country Songs</option>
  <option value="Blues" <? if ($genre == "Blues") echo "selected";?>>Blues Songs</option>
 </select>
 </form>
</div>
<div style="clear: both;">>/div>

<?

#actually show the table
$tblDemo->showTable();

View Example by Itself

Click here to view example outside of the template.

Recent Feedback

"Hello. And Bye." - Posted by XRumerTest on Sunday May 3rd, 2009 at 8:58pm

"Hello. And Bye." - Posted by XRumerTest on Monday May 4th, 2009 at 3:23am

"first of all: great work! thanx for this class!!
please give me a tip: when generating a new record i want to see the input form on top of the window. is this possible?!
have a nice weekend - i`m greeting from muenster - a town in the middel-west of germany. it rains.........

cordially,
wolga
" - Posted by wolga wibri on Friday May 8th, 2009 at 3:27am

"Great post! I`ll subscribe right now wth my feedreader software!" - Posted by JaneRadriges on Saturday Jun 13th, 2009 at 11:34pm

"The best information i have found exactly here. Keep going Thank you" - Posted by KattyBlackyard on Monday Jun 15th, 2009 at 12:08am

"Todd Cowle Municipal Bond Credit Report synthesizes, analyzes and presents aggregate credit information and trends in the municipal bond market. The report includes municipal bond rating information from the three major rating agencies – Moody’s Investor Services, Standard and Poor’s and Fitch Ratings." - Posted by fuccembef on Wednesday Mar 17th, 2010 at 12:10am

"Hi


G`night
" - Posted by Test on Tuesday May 18th, 2010 at 6:05am

"Thank you very well read allss textt about drsating and ilike it very much" - Posted by cASPERSEANAELE on Thursday May 20th, 2010 at 7:50pm

"just wanted to say that this sites is realy great and Im Glad that i found it

I`ve gotten exposed to quite a lot of stuff here and just wanted to give my 7 cents. Im about to write a fine article for this forum about
and I`ll publish it as soon as i finish it.

If anybody need some support about it, please MSG me.

Thank you.

on the other hand : If you got problems with other stuff ,
you should read this article here:

It`s a good thing. ;)

cheers!
" - Posted by unremoRoffLef on Thursday Jul 22nd, 2010 at 7:36am

"hi i am new here just wana say hi to all members" - Posted by starringmoviest on Friday Aug 20th, 2010 at 10:43am

Leave a Comment

Your Name      
Your Email   
Comment

 

"Very interesting class. Thanks a lot."
~gustavo

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