Newbie! Need some basic advice to start. Currently using MSSQL-PHP-APACHE2

Newbie! Need some basic advice to start. Currently using MSSQL-PHP-APACHE2

waolwaol Posts: 37Questions: 0Answers: 0
edited August 2009 in General
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
«1

Replies

  • orchid1orchid1 Posts: 18Questions: 0Answers: 0
    ouch! best thing you can do is look over the documentation

    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
  • waolwaol Posts: 37Questions: 0Answers: 0
    OK. Apache2 as Web Server is ok I assume right? And then you said tutorial for the server side. do you mean the zero configuration piece of code or what?
    this one?
    $(document).ready(function() {
    $('#example').dataTable();
    } );

    But do I need to have jquery installed as well?

    Thanks.
  • waolwaol Posts: 37Questions: 0Answers: 0
    BTW, I assume you have read what I'm currently doing and I assume that I can do a lot more with datatables.

    Please tell me I'm on the right track :)
  • orchid1orchid1 Posts: 18Questions: 0Answers: 0
    have you ever worked with xampp sounds like youd be better off using xampp to install your webserver and mysql on the localhost a.k.a your computer

    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
  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    Hi waol,

    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
  • waolwaol Posts: 37Questions: 0Answers: 0
    Hi 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
  • waolwaol Posts: 37Questions: 0Answers: 0
    Allan,

    OOOPS

    Apparently my code is 2960 characters too long :( and I don't have a link for it.
    Alternatives?
  • waolwaol Posts: 37Questions: 0Answers: 0
    Hi Orchid 1,

    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
  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    Hi Salvo,

    You could stick your code into paste bin for us: http://pastebin.com/

    Thanks
    Allan
  • waolwaol Posts: 37Questions: 0Answers: 0
    Hi Allan,


    It should be there now.

    Please let me know if you can see it or not.

    Thanks,
    Salvo
  • fliesflies Posts: 35Questions: 0Answers: 0
    It might be but you must give a link to specified paste :)
  • waolwaol Posts: 37Questions: 0Answers: 0
    like this I guess


    http://pastebin.com/m3f1b9509
  • fliesflies Posts: 35Questions: 0Answers: 0
    edited August 2009
    Your table is not in correct datatables format it should be (take a closer look at thead and tbody section - thead means header of table with column names, tbody is the content):
    [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]
  • fliesflies Posts: 35Questions: 0Answers: 0
    edited August 2009
    Btw. I am a little lazy to check it line by line, so could you also show us the output of this file? I think your HTML could be damaged after first look...
  • waolwaol Posts: 37Questions: 0Answers: 0
    Are you saying that all I have to do is correct the table and put those lines at the beginning?

    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?
  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    Hi waol,

    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
  • waolwaol Posts: 37Questions: 0Answers: 0
    Hi 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
  • fliesflies Posts: 35Questions: 0Answers: 0
    You better send it to allan, I'm not a developer of datatables and therefore he is the right person (but you could always strip the data) and provide source without company details.
  • fliesflies Posts: 35Questions: 0Answers: 0
    You also need to attach datatables.js file to your source... Everything is in documentation
  • waolwaol Posts: 37Questions: 0Answers: 0
    Hi Flies,

    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
  • waolwaol Posts: 37Questions: 0Answers: 0
    I guess the one you meant is jquery.dataTables.js in the media/js folder right?
  • fliesflies Posts: 35Questions: 0Answers: 0
    edited August 2009
    First: jquery.js
    then: jquery.dataTables.min.js

    Also look to examples directory, it might give you some hints :)
  • waolwaol Posts: 37Questions: 0Answers: 0
    Flies,

    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.
  • fliesflies Posts: 35Questions: 0Answers: 0
    Whole page is a documentation. You must read through examples under the usage section...

    I tell you: look at the examples directory in the zip you downloaded you got whole page layout needed there :)
  • waolwaol Posts: 37Questions: 0Answers: 0
    Just finished my first page.

    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
  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    DataTables can obtain data in several different ways:

    - 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
  • waolwaol Posts: 37Questions: 0Answers: 0
    Hi 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?
  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    It sounds like DataTables isn't seen the full data set for some reason. Could you paste your code again please? Also you might was to disable bSortClasses if you are dealing with 1000 rows on the client side :-)

    Allan
  • waolwaol Posts: 37Questions: 0Answers: 0
    Here:
    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.
  • waolwaol Posts: 37Questions: 0Answers: 0
    Hi Allan,

    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
This discussion has been closed.