Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81990

HTML Required for MySQL database

$
0
0
Hi,
What is the correct HTML required on my webpage page for DataTables to work with a MySQL database? I cannot see in the extensive documentation, under Server-side (MySQL); what the main HTML tags/structure on my webpage should be? Here's what I have so far, but the (MySQL sourced) DataTable is not appearing on my webpage?

HTML page:
 <div id="retrievepetname">
                <button id="retrievepetnamebtn">Show Pet Name Database</button>
            </div>
            
            <div id="petnametablediv">
                <table id="petnametable">
                    <thead>
                        <tr>
                            <th>Column 1</th>
                            <th>Column 2</th>
                            <th>etc</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>Row 1 Data 1</td>
                            <td>Row 1 Data 2</td>
                            <td>etc</td>
                        </tr>
                        <tr>
                            <td>Row 2 Data 1</td>
                            <td>Row 2 Data 2</td>
                            <td>etc</td>
                        </tr>
                    </tbody>
                </table>
            </div> 

Javascript file:
 //  PHP MySQL Page: Show Petname Result Table

$(document).ready(function() {
    $("#retrievepetnamebtn").click(function() {
    
    $("#retrievepetname").hide();

    $('#petnametable').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": 'getpetnamefromdb.php'
        } );
    })
} ); 

PHP File: (note this file 'getpetnamefromdb.php' is located in the sam dir as index.html)
 <?php

/* This Script Gets PetName from MySQL DB, for DataTable use  */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * Easy set variables
	 */
	
	/* Array of database columns which should be read and sent back to DataTables. Use a space where
	 * you want to insert a non-database field (for example a counter or static image)
	 */
	$aColumns = array( 'id', 'petname' );
	
	/* Indexed column (used for fast and accurate table cardinality) */
	$sIndexColumn = "id";
	
	/* DB table to use */
	$sTable = "table1";
	
	/* Database connection information */
	$gaSql['user']       = "root";
	$gaSql['password']   = "notshown";
	$gaSql['db']         = "jasontaylorwebsite2";
	$gaSql['server']     = "localhost";
	
	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * If you just want to use the basic configuration for DataTables with PHP server-side, there is
	 * no need to edit below this line
	 */   
( The rest of this php file has been deliberately omitted)

Thank you, in advance for your help.

Viewing all articles
Browse latest Browse all 81990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>