Newbie! Need some basic advice to start. Currently using MSSQL-PHP-APACHE2
Newbie! Need some basic advice to start. Currently using MSSQL-PHP-APACHE2
Hi guys,
I want to apologise in advance for any silly question I'm about to pose.
I've come accross datatables and it seems that it can really help me in my job.
I have written a php page that queries a Ms-sql database, retireve a bunf of data and than put them into a table to be displayed by a browser. I have both php and a html table page version.(the html one written by php)
I've gone through some of the examples of what can be done with DataTables and I'm truly impressed; my problem?
I'm not a programmer but come from a Network background so I'd like some basic advice on how to start using this magic tool. Assuming it's the right one and can do what I need: sort asc/desc any column, change sorting, give colors to cells/columns depending on conditions, have clickable cells that will explode in new queries/ page(all stuff I'm currently very painfully doing in php).
I'm not quite getting the A-B-C here, don't even the pieces of codes needed and where to put them; I should be able to figure out more by myself when given the start.
Thanks all, I can provide my current code if you want to have an idea of what I'm doing.
Thanks,
Salvo
I want to apologise in advance for any silly question I'm about to pose.
I've come accross datatables and it seems that it can really help me in my job.
I have written a php page that queries a Ms-sql database, retireve a bunf of data and than put them into a table to be displayed by a browser. I have both php and a html table page version.(the html one written by php)
I've gone through some of the examples of what can be done with DataTables and I'm truly impressed; my problem?
I'm not a programmer but come from a Network background so I'd like some basic advice on how to start using this magic tool. Assuming it's the right one and can do what I need: sort asc/desc any column, change sorting, give colors to cells/columns depending on conditions, have clickable cells that will explode in new queries/ page(all stuff I'm currently very painfully doing in php).
I'm not quite getting the A-B-C here, don't even the pieces of codes needed and where to put them; I should be able to figure out more by myself when given the start.
Thanks all, I can provide my current code if you want to have an idea of what I'm doing.
Thanks,
Salvo
This discussion has been closed.
Replies
first thing first get it working as a basic version on your server
have you got it even working in the basic version on your server???
start by installing the tutorial for the server side
do that and then come back tot he forum that should get you familiarized with the basics
goodluck
this one?
$(document).ready(function() {
$('#example').dataTable();
} );
But do I need to have jquery installed as well?
Thanks.
Please tell me I'm on the right track :)
in anycase if you do not have it installed download xampp and install it it will do everything for you as far as installing mysql and apache and even an ftp and email server
all you have to do is click like two buttons
when you run it on your computer make sure you run xampp as administrator by right clicking the icon on the desktop and chosing adminstrator if you are running vista
can't help you beyond that in s=installing the server
however if you do already have the server running
and mysql running then yes you will need to download jquery but for now you will only need the core file
something like jquer.core.js or something like that
anyways
to answer your question directly No "not the zero configuration version" of dataTable it does not connect to mysql
use the version in the DataTable folder under the examples folder named somthing like server side
and then do a search on the forums for mysql or mysqli or mysql improved there is more informaton there
keep working at it
youll get ther don't get over whelmed trouble shoot it at the very wors youll get it running in like a day or two but you will learn a ton
dataTable rocks it has a ton of features and I am just learning them myself
let me know when you have tweaked with the server_side.php and doen everything else
From your original explanation it sounds like your PHP script is writing out a standard HTML table - is this correct? If so then you want to be using something like the zero configuration setup: http://datatables.net/examples/example_zero_config.html
The server-side processing option is considerably more complicated and requires a script which will answer a request from DataTables for every draw (i.e. page turn, sorting etc).
Perhaps you could post your code, or better yet a link, which will help us to help you :-)
Regards,
Allan
Thank you for your feedback.
I think you're right. Let me put the code here so at least you'll have an idea of where I am now.
This below is let's say the simple version of the php page.
the one I still call directly to view the table, then there is another version where I write on html file: the reason is just to have less hit to the database if multiple users load the page.
Here:
and recall, it's my first time I'm coding so I'm proud of my page, please don't laugh at it :P
thanks in advace,
Salvo
OOOPS
Apparently my code is 2960 characters too long :( and I don't have a link for it.
Alternatives?
Thank you for your feedback.
Sorry if I wasn't clear.
I've already have all running, apache server with php code to query an esternal ms-sql database.
the php query creates a table, this is where I am now.
Now, I'll have also a look at the example in the folder you mentioned.
Thanks,
Salvo
You could stick your code into paste bin for us: http://pastebin.com/
Thanks
Allan
It should be there now.
Please let me know if you can see it or not.
Thanks,
Salvo
http://pastebin.com/m3f1b9509
[code]
Column 1
Column 2
etc
Row 1 Data 1
Row 1 Data 2
etc
Row 2 Data 1
Row 2 Data 2
etc
[/code]
Very important is to set "table_id"
And then in head section add:
[code]
$(document).ready(function() {
$('#table_id').dataTable();
} );
[/code]
mmmhhhhh.... sounds too simple.
You want a screenshot?
I'd rather to send it to you directly as there will be companies details in there.
Is this possible?
You can send me a link directly using datatables.net/contact . As flies states, DataTables required thead and tbody as shown here: http://datatables.net/usage
Allan
I can send you a screenshot and not a link as you won't be able to access it; It's in a private network.
I'll take care of modifying the page as per requirements also as you suggested.
The reason why I said it was too simple is because I thought I had to places some other files somewhere in the apache folders, is this not the case?
Let me know where I can send you a screenshot.
Cheers,
Salvo
Thank you. When you say documentation, where is it exactly? I've looked for it and expected to be in the "usage" but hadn't seen a proper guide. Am I missing something huge here?
DO I have to include something for jquery as well?
Thanks,
Salvo
then: jquery.dataTables.min.js
Also look to examples directory, it might give you some hints :)
Can you please point me to the documentation? In case I'm missing it.
Thanks for the 2 files to include.
Now that I know these are the ones needed I think I can start playing around.
I tell you: look at the examples directory in the zip you downloaded you got whole page layout needed there :)
This thing is AWESOME!!!!! I can hardly believe what I'm doing and watching
Thanks all.
What I'll have to do next:
-Change row, or column, or cell on specific conditions (entries retrieved from the databases or calculated variables).
-Have cells linked to retrieve other pages data.
I'm still using PHP to query MS-SQL database and fwrite to build the html page. Am I correct thinking that the DB can be queried directly?
Thanks,
Salvo
- From the DOM - http://datatables.net/1.5-beta/examples/data_sources/dom.html
- From a JS array - http://datatables.net/1.5-beta/examples/data_sources/js_array.html
- From a JSON file - http://datatables.net/1.5-beta/examples/data_sources/ajax.html
- From server-side processing - http://datatables.net/1.5-beta/examples/data_sources/server_side.html
Which one of these is best for you depends on what you want to do and how much data you have. Note that DataTables itself does not query the database, it will either respond to a server-side script which does the query, or request that the server-side script do the query.
Regards,
Allan
I guess I can wait to look to those link, I'm really getting overwhelmed here :).
Got a problem at the moment: I'm retrieving almost 1K rows and also with the basic installation (I've reverted back to get things simple) I can't keep the number of rows specified in "Show entries" filter. Everything will be displayed anyway; however only the number of entries selected in the "show filter" will have colors and only on those the Search will work.
Any enlightening idea?
Allan
http://pastebin.com/m3bdb551c
You'll notice I'm still struggling with colors...
About bSortClasses, where should I disable it? In the initialisation code?
Does that mean that this is a feature and there are more than the 5 in the example below?
$(document).ready(function() {
$('#example').dataTable( {
"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bSort": false,
"bInfo": false,
"bAutoWidth": false } );
} );
or is it bSort? As I kind od really need it.
I saw bSortCalsses and try to remove it but still the same. I have actually 2 pages, in one I retrieve no more than 30 rows from the database but still have the same issue with pagination.
It looks like the first time i load the page I'll see all the rows and only if I start using the forward and back buttons it'll show the number choose entries, but loading the page again rebrakes it.
Any idea where I should keep looking ?
Thanks,
Salvo