我有这个代码可以完美地显示项目,但是弹出一个错误,我必须点击“确定”查看页面
我已经在网上搜索过,据我了解,这与标题表的列比数据本身多有关,我试图解决这个问题,但由于我是新手(菜鸟),所以一无所获:/
如果有人能对此有所了解,那就太好了!:)
错误
DataTables warning (table id = 'example'): Requested unknown parameter '0'
from the data source for row 0
我的代码
<?php
//include database connection
include 'db_connect.php';
//query all records from the database
$query = "select * from repair_jobs";
//execute the query
$result = $mysqli->query( $query );
//get number of rows returned
$num_results = $result->num_rows;
//this will link us to our add.php to create new record
if( $num_results > 0){ //it means there's already a database record
//start table
//creating our table heading
echo "<table id='example' cellpadding='0' cellspacing='0' border='0' class='display' >";
echo "<thead><tr>";
echo "<th>Client</th>";
echo "<th>Type</th>";
echo "<th>Labour</th>";
echo "<th>ourcosts</th>";
echo "</thead></tr><tbody><tr class=\"gradeX\">";
//loop to show each records
while( $row = $result->fetch_assoc() ){
//extract row
//this will make $row['firstname'] to
//just $firstname only
extract($row);
//creating new table row per record
echo "<tr>";
echo "<td>{$client}</td>";
echo "<td>{$type}</td>";
echo "<td>{$labour}</td>";
echo "<td>{$ourcosts}</td>";
echo "</td>";
echo "</tr>";
}
echo "</table>";//end table
}else{
//if database table is empty
echo "No records found.";
}
//disconnect from database
$result->free();
$mysqli->close();
?>
它显示正常,但这个错误让我感到困惑。