Newbie - HELP!
Newbie - HELP!
i am attempting to use the DataTables plugin but cant quite work it all out. right bits in the header... calling a php file to query the server... nothing displays except the column names. I am REALLY new to JQuery but have experience in php. Any ideas where i might be going wrong? help much appreciated. thanks in advance.
This discussion has been closed.
Replies
I'm going to need a little more information that than to be able to help I think :-). What kind of data source are you using - are you just trying to enhance an HTML table for example? What initialisation are you using for DataTables? It would be very helpful if you could give me a link to your page.
Allan
its on an internal server at the moment.
I have this in the header:
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "./server_processing.php"
} );
} );
then entered the relevent details into server_processing....
and then i am embarrassed to say i hit a bit of a wall.
i didn't know how to call up an instance of your datagrid in the page...
so i looked at the source of a page on your site but still couldn't get it to work.
yeah - i know its all really basic but i think its my blond hair holding me back.
blond again!
its calling a table in mysql
heres what i am trying to improve:
[code]
<?php
$sql2 = "SELECT COUNT(id) FROM suggestions";
$rs_result2 = mysql_query($sql2);
$row2 = mysql_fetch_row($rs_result2);
$total_records = $row2[0];
$total_pages = ceil($total_records / $r);
?>
Date
Notes
Completed
Page
<?php
for ($j=1; $j<=$total_pages; $j++) {
echo "".$j." | ";
} ;
?>
<?php
$jj== 1;
while ($row = mysql_fetch_assoc($rs_result)) {
$jj++;
$id = $row["id"];
$comp = $row["complete"];
if($comp == 'Y'){$comp1 = 'Yes';}else{$comp1 = 'No';}
if($jj % 2){echo "";}else{echo "";}
?>
<? echo $row["date"]; ?>
<? echo $row["notes"]; ?>
<? echo $comp1; ?>
<? echo "view" ?>
<?php
};
?>
Page
<?php
for ($i=1; $i<=$total_pages; $i++) {
echo "".$i." | ";
} ;
?>
[/code]
Allan
So, assuming you are just enhancing a plain HTML table you would want to do something like that shown in this example: http://datatables.net/examples/basic_init/zero_config.html
Allan
[/code]
@import "../../media/css/demo_page.css";
@import "../../media/css/demo_table.css";
$(document).ready(function() {
$('#example').dataTable();
} );
[/code]
You may need to alter the paths for the include files. You might also need to change the selector for the dataTable() initialisation.
Allan
Allan
Allan
It was a long weekend and i was extremely tired and blonde!
I took it all back to basics and resolved the problem.
a combination of php mysql jquery and some sleep.
code enclosed in case someone else needs a light shining in their mental darkness.
Thanks again for your assistance.;))
[code]
date
notes
status
actions
<?php
include("../../connection/connectdb.php");
$query = "SELECT * FROM suggestions ";
$result = mysql_query($query);
$num = mysql_num_rows ($result);
if ($num > 0 ) {
$i=0;
while ($i < $num) {
$uid = mysql_result($result,$i,"uid");
$date = mysql_result($result,$i,"date");
$notes = mysql_result($result,$i,"notes");
$complete = mysql_result($result,$i,"status");
$id = mysql_result($result,$i,"id");
echo "";
echo "$date";
echo "$notes";
echo "$status";
echo "view";
echo "";
++$i; }
echo ""; } else { echo "The database is empty"; }?>
date
notes
status
actions
[/code]