我想從4個消息後面選擇表中的最後12個。 我試過,但沒有results.I得到未定義$新聞SQL - select id其中id不在數組中
public function get_all_news_home()
{
$news = array();
# ne conectam la baza de date
$this->load->database();
# selectam stirile de top
$last_news_query = $this->db->query("SELECT * FROM News WHERE Type = 1 AND Ready='Y' ORDER BY Date DESC LIMIT 4");
$last_news = $this->db->query($last_news_query);
$last_news = ($last_news->num_rows()) ? $last_news->result_array() : NULL;
foreach ($last_news as $ln)
{
array_push($news,array('id' => $ln['ID']));
}
$all_news = $this->db->query("SELECT * FROM News WHERE News.Ready = 'Y' AND News.ID NOT IN ('$news') ORDER BY Date DESC LIMIT 12");
if($all_news->num_rows())
{
$all_news = $all_news->result_array();
}
else
{
$all_news = NULL;
}
return $all_news;
}
幫我please.How我可以排除第4號
你缺少一線分號在'$新聞=陣列();'。 – Rikesh
在代碼中存在 – user3532183
並從函數get_all_news_home中獲取'$ news'變量的位置? – Rikesh