Hello.
May I please enquire about DataTables and inserting either a database or array?
I've managed to some-how get an example DataTable to display in an html page. The example table has 57 entries in it (however I've cut it down to 2 in this question). I would like to please ask, how do I insert a database and display results from the database into the DataTable? Or should I create an array and some-how insert the array into the DataTable?I don't know which is better, database or array, I don't know how to proceed.
Could anyone please guide me?
My sample code is:-
: The php code above dosn't work, as it echos the word echo""; 4 times.
If I create a separate php file, to access the database within the <table>, would this not work?
I just don't know how to proceed.
I'd be grateful for any help.
Thank You.
May I please enquire about DataTables and inserting either a database or array?
I've managed to some-how get an example DataTable to display in an html page. The example table has 57 entries in it (however I've cut it down to 2 in this question). I would like to please ask, how do I insert a database and display results from the database into the DataTable? Or should I create an array and some-how insert the array into the DataTable?I don't know which is better, database or array, I don't know how to proceed.
Could anyone please guide me?
My sample code is:-
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Landing Page - Start Bootstrap Theme</title>
<!-- Bootstrap core CSS -->
<link href="/layout/public/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom fonts for this template -->
<link href="/layout/public/vendor/fontawesome-free/css/all.min.css" rel="stylesheet">
<link href="/layout/public/vendor/simple-line-icons/css/simple-line-icons.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
<!-- Custom styles for this template -->
<link href="/layout/public/css/landing-page.min.css" rel="stylesheet">
<script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script>
<!-- Data Table-->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/2.1.5/css/dataTables.dataTables.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/3.1.2/css/buttons.dataTables.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/staterestore/1.4.1/css/stateRestore.dataTables.css">
</head>
<body>
<?php
if(session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
?>
<!-- Navigation -->
<nav class="navbar navbar-light bg-light static-top">
<div class="container">
<!--<a class="navbar-brand"><?= $_SESSION['settings_title'] ?></a>-->
<a class="navbar-brand" href="#">Start Bootstrap</a>
<a class="btn btn-primary btn-sm" href="regsignin.php">Sign In</a>
</div>
</nav>
<!------------------------------------------------------------------------------------------------------------------------------------------------------------->
<table id="example" class="display nowrap" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011-04-25</td>
<td>$320,800</td>
</tr>
<?
for ($s=1; $s=50; $s++) {
echo "<tr>";
echo "<td>Title Header:- ".$s."</td>";
echo "<td>Description:- ".$s."</td>";
echo "<td>url: ".$s."</td>"
echo "<td>".$s."</td>";
echo "<td>2011-04-".$s."</td>";
echo "<td>$320,800</td>";
echo"</tr>";
}
?>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011-07-25</td>
<td>$170,750</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
</table>
<!--------------------------------------------------------------------------------------------------------------------------------->
<!-- Bootstrap core JavaScript -->
<script src="layout/public/vendor/jquery/jquery.min.js"></script>
<script src="layout/public/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTable -->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/2.1.5/js/dataTables.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/staterestore/1.4.1/js/dataTables.stateRestore.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/staterestore/1.4.1/js/stateRestore.dataTables.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.1.2/js/dataTables.buttons.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.1.2/js/buttons.dataTables.js"></script>
<script type="text/javascript" src="/layout/public/js/datatable.js"></script>
<!--<script type="text/javascript" src="/layout/public/js/data_array.js"></script>-->
</body>
</html>
: The php code above dosn't work, as it echos the word echo""; 4 times.
If I create a separate php file, to access the database within the <table>, would this not work?
I just don't know how to proceed.
I'd be grateful for any help.
Thank You.