Change static data array to database query results in DataTables

Hello, I created a DataTables jQuery table that worked good using a static data array. But I now need to use database query results. I have little experience with javascript, I just need to get this one search page to work. Thanks so much for any help…

 $connect = mysqli_connect("localhost", "user123X", "pass123X", "page_list");  
 $query ="SELECT * FROM page_list ORDER BY page_name";  
 $result = mysqli_query($connect, $query);  
 <!DOCTYPE html>
  <script type="text/javascript" src="jQuery-3.2.1/jquery-3.2.1.min.js"></script>
  <script type="text/javascript" src="DataTables-1.10.16/js/jquery.dataTables.min.js"></script>
  <link rel="stylesheet" type="text/css" href="DataTables-1.10.16/css/jquery.dataTables.min.css"/>
  <script src=""></script>

  <style type="text/css">

$(document).ready(function() {
    "ajax": 'array.txt',
        "columns": [
            { "data": "page_name" },
            { "data": "page_url",
         "render": function(data, type, row, meta){
            if(type === 'display'){
		   data = '<a href="' + data + '" target="_blank">More Info</a>'
            return data;


<p>Top of html...</p>
<table class="display" id="example">
            <th><p>Page Name</p></th>
            <th>Page url</th>


the only purpose of jquery DataTables is display the data in html

But we can just construct the a table using php + html code:

if you want to use jquery DataTable you should make an ajax call.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.