I'm following a php and crud tutorial from youtube using php and mysql and I'm trying to use datatables to do the search and pagination stuff.
I have a ton of code so not sure what bits might be useful in finding what the problem is.
The error that keeps popping up is
Datatables warning (table id = 'datatables_table_0') requested unknown parameter '0' for row 0.
I need to get rid of this error.
Please can anybody help?
index.php
?php include_once( 'views/header.php' );
include_once('libs/getData.php');
?>
<script type ="text/javascript" src="js/jquery.js"></script>
<script type ="text/javascript" src="js/datatables.js"></script>
<script type ="text/javascript">
$(function(){
$('table.table').DataTable();
})
</script>
<h2 class="left"> Records From Some Table </h2>
<span class="right"><a href="create_new.php" class="btn btn-success">Insert New Value</a></span>
<div class="clear"></div>
<div class="mainDiv">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<?php
if($data !==0)
{
foreach($fields_name as $f)
{
echo '<th>'.$f.'</th>';
}
echo '<th>Actions</th>';
}
?>
</tr>
</thead>
<tbody>
<tr>
<?php
if($data !== 0)
{
foreach($data as $key => $value)
{
echo '<tr>';
foreach($fields_name as $f)
{
echo '<td>'.$value[$f].'</td>';
}
echo '<td><a href="edit.php?id='.$value['id'].'"><i class="icon-edit"></i></a> <a href="delete.php?id='.$value['id'].'"><i class="icon-trash"></i></a></td>
</tr>';
}
}
?>
</tr>
</tbody>
</table>
</div><!-- end mainDiv -->
</div><!-- end container -->
</body>
</html>
header.php
<?php include_once('libs/listTables.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="index.php">
Database Manager
</a>
</div>
</div>
</div><!-- end navbar -->
<div class="container">
<div class="table_switcher">
<form class="well form-inline" method="post" action="switch_tables.php?referrer=<?php echo $_SERVER['REQUEST_URI']; ?>">
<label for="Table Name">Table Name</label>
<select name="table_name">
<?php
echo '<option value="'.$session_table_name.'" selected="selected">'.$session_table_name.'</option>';
foreach($tables_left as $key => $value)
{
echo '<option value="'.$value.'">'.$value.'</option>';
}
?>
</select>
<input type="submit" name="switch_table" value="Switch Table" class="btn btn-primary"/>
</form>
</div><!-- end table_switcher -->
<?php
if(!isset($_SESSION['SESSION_TABLE_NAME']))
{
echo '<div class="alert alert-error"><p>Select a table to get started </p></div>'; ;
die;
}
?>