I want to show all the rows in the table and get the title and search the title in another table. If I echo the total number(816) of rows it's correctly showing. But if add the below code Its showing only(414) results from the table.
$viewss1=$con->query("SELECT COUNT(reference_id) FROM reference WHERE
reference LIKE '%$paper_title%'");
$cview1=$viewss1->fetch_row();
$countt1=$cview1[0];
If I add it showing half results. Why was that?. I don't know why. MY full code attached below. Thank you.
$sql="SELECT * FROM table";
$result=$con->query($sql);
$record=array();
if($result)
{
if($result->num_rows)
{
while($row=$result->fetch_object())
{
$record[]=$row;
}
}
}
foreach($record as $r)
{
$paper_title=$r->paper_title;
echo $paper_title;
// If i add the below code it shows half results.
$viewss1=$con->query("SELECT COUNT(reference_id) FROM reference WHERE
reference LIKE '%$paper_title%'");
$cview1=$viewss1->fetch_row();
$countt1=$cview1[0];
echo "<br>";
echo $r->upload_paper_id;
echo $countt1;
echo "<br>";
}
最后我得到了答案。如果任何行有空值,它将停止循环。所以最好检查是否为空。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.