MYSQL My First DATAGrid DataTables Question.

MYSQL My First DATAGrid DataTables Question.

SalmanSSalmanS Posts: 102Questions: 12Answers: 0

Please can someone point me how i can retrive mysql data in a grid using datatables library with pagination and search.

I would like the grid to show a search column and also a drop down list of the grid columns to add or remove from grid display.

For delete option i would like to have an on click of the table to delete the selected row but using modal window rather using the default alert() method.

Any guidance is highly appreciated.
Thank you

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,664Questions: 1Answers: 10,095 Site admin

    Hi,

    I've replied to your same question by e-mail:

    It sounds like you might want to have a look at Editor, which provides server-side libraries to get the data from the server as well as delete options.

    You replied asking for help, Rather than having the discussion both my e-mail and here, let's have it just here. What help do you need? Have you installed the Editor trial?

    Allan

  • SalmanSSalmanS Posts: 102Questions: 12Answers: 0

    Hi Allan,

    Apologies, i just want to add the datatables grid in my welcome page.
    I cannot find any example on this website where you can call data from a table to a datatables.

    I my be wrong.

    $(document).ready(function() {
    $('#example').DataTable();
    } );

    i got a welcome.php page and it got some div elements for navigation.

    i would like to add a div element with ID=example and pull a basic data with some columns with pagination and search.

    How could i do this.

    please guide me or give me a link where you are fetching data from a table using mysql php and datatables please.

    Salman.

  • allanallan Posts: 61,664Questions: 1Answers: 10,095 Site admin

    DataTables is a client-side library. It will not pull information from a MySQL database or any other type of database. You can use server-side libraries such as those provided by Editor (see this example which reads live from a database), or any other script / program on the server-side which will retrieve the data from the database. Again, DataTables will not do that nor is it designed to.

    See the documentation here for how to Ajax load data if you output the information from the database as JSON.

    If you need help writing a script that will read information from a database, I'd suggest asking on StackOverflow, or looking for a tutorial on the topic for whatever server-side environment you are using.

    Allan

  • SalmanSSalmanS Posts: 102Questions: 12Answers: 0

    You mean to say I can call staff.php

    My staff.php file contains the following and it doesnt work.

    <?php
    include_once("db_connect.php");

    $sql_query = "SELECT id as emp_id, employee_name as emp_name, employee_salary as emp_salary, employee_age as emp_age FROM employee ";

    <?

  • allanallan Posts: 61,664Questions: 1Answers: 10,095 Site admin
    Answer ✓

    All that is doing is defining a string in PHP. It isn't actually executing an SQL query, nor is it returning anything to the client-side.

    This tutorial among many others on the web might help.

    Allan

This discussion has been closed.