Need help with fnFilter

Need help with fnFilter

bohrsmodelbohrsmodel Posts: 4Questions: 0Answers: 0
edited March 2014 in General
I want to filter based on a selection box's value. When I use the built in search box, it works, but when I set the fnFilter function for the selection's keyup event, it doesn't work. Here's my code:

<?php
/*
* DATABASE CONNECTION
*/

// DATABASE: Connection variables
$db_host = "localhost";
$db_name = "snort_mysql";
$db_username = "root";
$db_password = "";

// DATABASE: Try to connect
if (!$db_connect = mysql_connect($db_host, $db_username, $db_password))
die('Unable to connect to MySQL from ajax-form.');
if (!$db_select = mysql_select_db($db_name, $db_connect))
die('Unable to select database');

/*
* DATABASE QUERY
*/

$query="SELECT ProjectIndex, ProjectName, Op_NUM , ArchivedCamera, ArchivedFireControl FROM ProjectInfo WHERE (ArchivedCamera=0 AND ArchivedFireControl=0) ORDER BY ProjectName";
$result = mysql_query ($query);
?>


<!DOCTYPE html>





Datatables


@import "media/css/jquery.dataTables.css";











$(document).ready(function()
{

$("#tabs").tabs
(
{
activate: function(event, ui)
{
var jqTable = $('table.display', ui.newPanel);
if ( jqTable.length > 0 )
{
var oTableTools = TableTools.fnGetInstance( jqTable[0] );
if ( oTableTools != null && oTableTools.fnResizeRequired() )
{
jqTable.dataTable().fnAdjustColumnSizing();
oTableTools.fnResizeButtons();
}
}
}
}
);


/* Init DataTables */
var oTable_books = $('#books').dataTable
({
"sDom": 'lrtip',
//"bPaginate": false,
// "bStateSave": false,
//"bFilter": false //disable search
"bDestroy": true,
"aaSorting":[[0, "desc"]],


"aoColumns":
[

{ "bSearchable": true}, //id
{ "bSearchable": false },//surname
{ "bSearchable": false },//name
{ "bSearchable": false },//title
{ "bSearchable": false },//published
{ "bSearchable": false } //whenread
]

});
/* Apply the jEditable handlers to the table */
oTable_books.$('td').editable( 'books_edit.php', {
"callback": function( sValue, y ) {
var aPos = oTable_books.fnGetPosition( this );
oTable_books.fnUpdate( sValue, aPos[0], aPos[1] );
window.location.reload();
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable_books.fnGetPosition( this )[2]
};
},
"height": "14px",
"width": "100%"
} );



$("id_selection").keyup( function () {
/* Filter on the column (the index) of this element */
oTable_books.fnFilter( this.value);
oTable_books.fnDraw();
} );

});




<?php

echo "";

echo "Select a Project:";
while($drop=mysql_fetch_array($result))
{
//data stored in $drop
echo "$drop[ProjectIndex], $drop[ProjectName] ";
}

echo ""; // Close list box
?>












Books
DVD
Music







<?php
$table="books";
$books_query = "show columns from $table";
$books_result = mysql_query($books_query);

while ( $books_row = mysql_fetch_assoc($books_result) )
{
$fieldname = $books_row['Field'];
//if ( $fieldname == 'id' ) continue;
echo "$fieldname";
}
?>



<?php
$books_query = "select * from $table";
$books_result = mysql_query($books_query);

while ( $books_row = mysql_fetch_assoc($books_result) )
{

$id = $books_row['id'];
//echo "";

//unset($books_row['id']);

foreach ($books_row as $key => $value)
{
echo "$value";
}
echo "";
}

?>














<!-- end tab 3-->
<!-- end tabs-->
<!-- end contents-->
This discussion has been closed.