0
我根據查詢的結果返回動態地生成表,但一切正常,表正在生成,數據表正在正確顯示。但記錄數是這裏的問題是,如果我得到10條記錄,它顯示了9條記錄。但表中有10條記錄。 請在這方面幫助我。 我的代碼: PHP代碼在使用數據表時,表中的記錄計數不正確顯示
mysql_select_db($database_finalkms, $finalkms);
$query_getcolumns = $qry;
$getcolumns = mysql_query($query_getcolumns, $finalkms) or die(mysql_error());
$row_getcolumns = mysql_fetch_assoc($getcolumns);
$totalRows_getcolumns = mysql_num_rows($getcolumns);
echo $totalRows_getcolumns;
表的代碼
if (($getcolumns)||(mysql_errno == 0))
{
echo "<table width='50%' class='table table-striped table-bordered table-hover' align='center' id='sample_2'>
<thead><tr>";
if (mysql_num_rows($getcolumns)>0)
{
//loop thru the field names to print the correct headers
$i = 0;
while ($i < mysql_num_fields($getcolumns))
{
echo "<th align='center'>". mysql_field_name($getcolumns, $i) . "</th>";
$i++;
}
echo "</tr></thead>";
echo "<tbody>";
//display the data
while ($rows = mysql_fetch_assoc($getcolumns))
{
echo "<tr>";
foreach ($rows as $data)
{
echo "<td align='center' width=''>". $data . "</td>";
}
}
}else{
echo "<td colspan='" . ($i+1) . "'>No Results found!</td></tr>";
}
echo "</tbody></table>";
}else{
echo "Error in running query :". mysql_error();
}
你能顯示'$ qry' – user2936213
$ data = json_decode(stripslashes($ _ POST ['data']),true); $ qry =「選擇」資產ID「,」; $ qry。= $ data; $ qry。=「from CompletedetailsTrans」; – Firoz
只需執行'echo $ qry;'並查看查詢並將該查詢放入phpmyadmin中,並檢查您獲得了多少行。另外使用'msqli'而不是'mysql'。 – user2936213