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
fldFilename | fldTitle | fldArtist | fldGenre |
---|---|---|---|
x | x | x | Pop |
-- | -- | -- | Pop |
-- | -- | -- | Pop |
-- | -- | -- | Pop |
-- | -- | -- | Pop |
-- | -- | -- | 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
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
G`night" - Posted by Test on Tuesday May 18th, 2010 at 6:05am
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