Server-side implementation problems

Server-side implementation problems

sroecosroeco Posts: 4Questions: 0Answers: 0
edited September 2010 in General
First, thanks for the amazing script. It couldn't be more exactly what I want.

I'm using it here- http://sroeco.com/solar/table/

However, being a php/ mysql novice, I've had trouble rendering the table with server-side processing. The table you see is 'ghetto code' not actually reading for my mySql database.

So, hopefully a simple fix - I need to know how to connect my server_processing.php with my table.html so that the table will populate with the data from the server instead of from the static code I've written into the current file.

Here are (what I believe) are the relevant codes:

First where I think my problem probably is... table.html Does the table id (id='tblMain') tell the script to populate it with the data?
[code]




Manufacturer
ID
Rating
Efficiency





Loading data from server...



[/code]

And here is the javascript in my table.html

[code]

$(document).ready(function() {
$('#tblMain').dataTable( {
"bPaginate": true,
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://sroeco.com/solar/table/server_processing.php",
"sPaginationType": "full_numbers",
"aaSorting": [[ 3, "desc" ]],
"aoColumns": [
{ "asSorting": [ "asc", "desc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ], "sType": "numeric" },
{ "asSorting": [ "desc", "asc" ], "sType": "numeric" }
]
} );
} );

[/code]

I apologize in advance if it's a simple fix.

Thanks,
Shawn

Replies

  • sroecosroeco Posts: 4Questions: 0Answers: 0
    Here's the server_processing.php

    [code]
    <?php
    $gaSql['user'] = "";
    $gaSql['password'] = "";
    $gaSql['db'] = "";
    $gaSql['server'] = "";
    $gaSql['type'] = "mysql";

    $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
    die( 'Could not open connection to server' );

    mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
    die( 'Could not select database '. $gaSql['db'] );

    /* Paging */
    $sLimit = "";
    if ( isset( $_GET['iDisplayStart'] ) )
    {
    $sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
    mysql_real_escape_string( $_GET['iDisplayLength'] );
    }

    /* Ordering */
    if ( isset( $_GET['iSortCol_0'] ) )
    {
    $sOrder = "ORDER BY ";
    for ( $i=0 ; $i
    [/code]
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    I think it would be worth having a go with this script: http://datatables.net/development/server-side/php_mysql . It should make things much easier if you are just using a flat table (i.e. no SQL joins). Stick the column names in, and the other information and away it goes...

    For the table ID, that is only used for the jQuery selector - DataTables doesn't actually use it internally (it does stick it on a few created elements for easy styling if you want, but nothing processing wise).

    Allan
  • sroecosroeco Posts: 4Questions: 0Answers: 0
    Thanks Allan. Actually, the old script ending up working. It looks like I was having incompatibility issues between my test server (MAMP) and the real thing. Once I tested the files from the host server, it all worked out.

    The new script looks promising though, so I might play with it until I get that to work, too.

    Thanks,
    Shawn
This discussion has been closed.