implementing server-side dataTable using SQL Server 2012 | PHP

implementing server-side dataTable using SQL Server 2012 | PHP

pjustindaryllpjustindaryll Posts: 13Questions: 4Answers: 0

I tried to search it for a week now, I did research here, check for guides in YouTube, and read guides in datatables.net, but still, I'm having problems implementing Server-Side dataTable using SQL Server 2012.

Can you guys please provide me with a step-by-step guide on how to implement it?

I stumble across this guide https://editor.datatables.net/examples/simple/join.html, and there's so many things in there that I don't understand.

If you guys could please simplify this? or convert this into a more readable code for newbies of this field, like me? Like for example.

index.php will consist of the following codes.

//codes goes here.
conn.php will consist of the following codes.

//codes goes here.
ajax.php will consist of the following codes.

//codes goes here.
and so on.. Or a sample script with like 2-3 columns.

I currently have a working code that only populates dataTable when the script is being called. I used AJAX and Javascript on it as well. I'm using sqlsrv as my connection for SQL Server 2012

It would lessen my coding time for more than 50% if I could have a guide in implementing Server-Side dataTable using SQL Server 2012 as most of my pages are dataTable-reliant.

Like for this line in Server Script

// DataTables PHP library
include( "../../php/DataTables.php" );
What is DataTables.php supposed to have inside? SQL connection? What does the guide mean by // DataTables PHP library?

It would be extremely great if you guys could share in a more understandable way the guide above.

Thank you.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 64,028Questions: 1Answers: 10,555 Site admin

    The first thing to check is - are you using Editor? If so, then carry on using the example you linked to - the full installation guide for the PHP libraries with Editor are available here. If you have any problems with any of the steps documented there, just let me know.

    If you aren't using Editor, then you'll need to look at third party scripts (such as this one - more linked from here), which are not supported by us, but might still help you get started.

    Allan

  • pjustindaryllpjustindaryll Posts: 13Questions: 4Answers: 0
    edited August 2019

    Allan, I'm having a problem. I created **datatables_demo ** table from https://editor.datatables.net/examples/sql/sqlserver.sql. It should work, right, with this confg.php?

    $sql_details = array(
    "type" => "Sqlserver", // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite" or "Oracle"
    "user" => "sa", // Database user name
    "pass" => "P@SSWORD", // Database password
    "host" => "MYPC\SQLSERVER", // Database host
    "port" => "", // Database connection port (can be left empty for default)
    "db" => "MYSERVER", // Database name
    "dsn" => "", // PHP DSN extra information. Set as charset=utf8mb4 if you are using MySQL
    "pdoAttr" => array() // PHP PDO attributes array. See the PHP documentation for all options
    );

    That's the only thing I changed. I followed the guide. What seems to be the problem? It's not showing any data in the dataTable.

    I'm receiving this error: file://datatables.net/tn/12

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @pjustindaryll ,

    The value for host, MYPC\SQLSERVER, looks like it could be wrong - that looks like a Windows domain path, rather than the resolvable name or IP address of the server. It would be worth changing that to an IP address and see if that helps,

    Cheers,

    Colin

  • allanallan Posts: 64,028Questions: 1Answers: 10,555 Site admin
    Answer ✓

    Also it sounds like you are loading the html file directly, rather than from a web-server. Browsers will all block file:// Ajax requests since allowing them would be a massive security issue.

    Allan

  • pjustindaryllpjustindaryll Posts: 13Questions: 4Answers: 0

    Thank you Allan and Colin! it worked!

This discussion has been closed.