我有这个代码可以完美显示项目,但弹出一个错误,我必须单击“确定”查看页面
我已经在网上搜索过,据我所知,这与标题表有更多的列而不是数据本身有关,我试图麻烦这个并且无处可去,因为我是新手(noob): /
如果有人能对此有所了解,那就太棒了! :)
错误
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();
?>
它显示正常,但这个错误使我感到困惑。