When I use PHP include to add the head section no data loads
When I use PHP include to add the head section no data loads
Link to test case: https://jsfiddle.net/sleepy_loco/8muh20r3/
Debugger code (debug.datatables.net): oloraz
Error messages shown: None
Description of problem: When I use PHP include to add the <head> section into the linkeddocs.php page, no data loads in the table. There are no console errors. Tailwinds css is loading. The include on banner.php is working.
If i have the same data from inside head.php manually in linkeddocs.php it works?!!!? I am so confused.
Head.php
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- <title>DataTables Editor - home</title> -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jqc-1.12.4/moment-2.29.4/dt-1.13.8/b-2.4.2/date-1.5.1/sl-1.7.0/datatables.min.css">
<link rel="stylesheet" type="text/css" href="css/generator-base.css">
<link rel="stylesheet" type="text/css" href="css/editor.dataTables.min.css">
<script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/v/dt/jqc-1.12.4/moment-2.29.4/dt-1.13.8/b-2.4.2/date-1.5.1/sl-1.7.0/datatables.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/dataTables.editor.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/table.home.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
</head>
linked docs.php
<?php $qs = '';
if (isset($_SERVER['QUERY_STRING'])) {
$qs = substr(str_replace('%20', ' ', $_SERVER['QUERY_STRING']), 7);
} ?>
<!doctype html>
<html>
<?php
include ('partials/head.php');
include('partials/banner.php');
<?php
>
">
DataTables Editor Linked Docs Home
<?php
if (str_contains($qs, 'Class Price') && !str_contains($qs, 'Release')) {
include('partials/searchtip.php');
};
?>
?>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="linkeddocs" width="100%">
<thead>
<tr>
<th>Left Menu Header</th>
<th>Left Menu Content</th>
<th>Main Content</th>
<th>Main Content Heading</th>
<th>Content Heading</th>
<th>Root Folder</th>
<th>Sub Folder one</th>
<th>Sub Folder Two</th>
<th>File Name</th>
<th>year</th>
<th>Month</th>
<th>Link</th>
<th>Year Group</th>
<th>Hide Content</th>
</tr>
</thead>
</table>
</div>
</body>
</html>
table.linkeddocs.js
/*
* Editor client script for DB table linkeddocs
* Created by http://editor.datatables.net/generator
*/
(function($){
$(document).ready(function() {
var selector = document.querySelector("#qs").value;
var editor = new DataTable.Editor( {
ajax: 'php/table.linkeddocs.php',
table: '#linkeddocs',
fields: [
{
"label": "Left Menu Header:",
"name": "lmh"
},
{
"label": "Left Menu Content:",
"name": "lmc"
},
{
"label": "Main Content:",
"name": "mc"
},
{
"label": "Main Content Heading:",
"name": "mch"
},
{
"label": "Content Heading:",
"name": "ch"
},
{
"label": "Root Folder:",
"name": "rf"
},
{
"label": "Sub Folder one:",
"name": "sf1"
},
{
"label": "Sub Folder Two:",
"name": "sf2"
},
{
"label": "File Name:",
"name": "fn"
},
{
"label": "year:",
"name": "year"
},
{
"label": "Month:",
"name": "month"
},
{
"label": "Link:",
"name": "link"
},
{
"label": "Year Group:",
"name": "yeargroup"
},
{
"label": "Hide Content:",
"name": "hc"
}
]
} );
var table = new DataTable('#linkeddocs', {
dom: 'Bfrtip',
ajax: 'php/table.linkeddocs.php',
columns: [
{
"data": "lmh"
},
{
"data": "lmc"
},
{
"data": "mc"
},
{
"data": "mch"
},
{
"data": "ch"
},
{
"data": "rf"
},
{
"data": "sf1"
},
{
"data": "sf2"
},
{
"data": "fn"
},
{
"data": "year"
},
{
"data": "month"
},
{
"data": "link"
},
{
"data": "yeargroup"
},
{
"data": "hc"
}
],
select: true,
lengthChange: false,
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
],
search:{
"search": " "+selector,
"smart": false,
"regex": true,
// "caseInsen": true
}
} );
} );
}(jQuery));
table.linkeddocs.php
<?php
/*
* Editor server script for DB table linkeddocs
* Created by http://editor.datatables.net/generator
*/
// DataTables PHP library and database connection
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
// The following statement can be removed after the first run (i.e. the database
// table has been created). It is a good idea to do this to help improve
// performance.
$db->sql( "CREATE TABLE IF NOT EXISTS `linkeddocs` (
`id` int(10) NOT NULL auto_increment,
`lmh` varchar(255),
`lmc` varchar(255),
`mc` varchar(255),
`mch` varchar(255),
`ch` varchar(255),
`rf` varchar(255),
`sf1` varchar(255),
`sf2` varchar(255),
`fn` varchar(255),
`year` numeric(9,2),
`month` numeric(9,2),
`link` varchar(255),
`yeargroup` numeric(9,2),
`hc` numeric(9,2),
PRIMARY KEY( `id` )
);" );
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'linkeddocs', 'id' )
->fields(
Field::inst( 'lmh' )
->validator( Validate::notEmpty() ),
Field::inst( 'lmc' )
->validator( Validate::notEmpty() ),
Field::inst( 'mc' ),
Field::inst( 'mch' ),
Field::inst( 'ch' )
->validator( Validate::notEmpty() ),
Field::inst( 'rf' ),
Field::inst( 'sf1' ),
Field::inst( 'sf2' ),
Field::inst( 'fn' ),
Field::inst( 'year' )
->validator( Validate::minMaxNum( 0000, 9999 ) ),
Field::inst( 'month' )
->validator( Validate::minMaxNum( 1, 12 ) ),
Field::inst( 'link' )
->validator( Validate::url() ),
Field::inst( 'yeargroup' )
->validator( Validate::numeric() ),
Field::inst( 'hc' )
->validator( Validate::notEmpty() )
->validator( Validate::minMaxNum( 0, 1 ) )
)
->process( $_POST )
->json();
Thanks for your help in advance
Replies
I included the wrong table in head for the webpage i was trying to view.... I knew i should have went to lunch and came back and looked at it again.
<script type="text/javascript" charset="utf-8" src="js/table.home.js"></script>
feel free to close this.Hi,
Thanks for the update. Its amazing how many things lunch can solve - I do it myself all the time as well.
Allan