请帮我解释一下这段代码:
<?php
require 'connection.php';
$by = "Batch";
$query = 'SELECT * FROM post ORDER BY count DESC WHERE kategori="Batch" LIMIT 4';
$exquery = mysqli_query($conn,$query);
while($get = mysqli_fetch_array($exquery)){
echo '<div class="w3-container w3-quarter w3-mobile">';
echo '<a href="viewbatch.php?idpost='.$get['idpost'].'"target="_blank">';
echo '<div class="column w3-mobile w3-border-blue w3-bottombar w3-border">';
echo '<div class="post-module">';
echo '<div class="thumbnail"><img src="'.$get['pictsource'].'" />';
echo '</div>';
echo '<div class="post-content">';
echo '<h1 class="title">'.smart_wordwrap($get['judulpost'], 11).'</h1>';
echo '<h2 class="sub_title">'.$get['tanggalpost'].'</h2>';
echo '<p class="description">'.smart_wordwrap(substr($get['sinopsis'], 0, 12)).'....'.'</p>';
echo '<div class="post-meta"><span class="comments"><i class="fa fa-user"></i><a href="#"> '.$get['adminposting'].'</a></span></div>';
echo '</div></div></div></a></div>';
}
?>
我的代码有一个php错误:
警告:mysqli_fetch_array()要求参数1为mysqli_result,第110行的/storage/ssd3/441/2169441/public_html/newennime/index.php中给出布尔值
该代码有什么问题,请告诉我如何修复它
抱歉我的英文不好
答案 0 :(得分:2)
$result = DB::table('users')
->leftJoin('post', function ($join) {
$join->on('users.id', '=', 'post.user_id');
})
->orderBy('users.id', 'desc')
->get();
子句将首先出现WHERE
,并且在任何情况ORDER BY
都会出现。
希望这会有所帮助。
LIMIT
答案 1 :(得分:1)
return => count(Name)
by应该在Order
之后:
Where
答案 2 :(得分:0)
&#39;按顺序排列&#39;是在&#39;之前&#39;在sql查询中。 count也是一个mysqli函数,因此需要在Route::get('job/detail/{job}/action', 'JobController@finish');
public function finish($id)
{
Job::find($id)->update(['status' => '2']);
}
<p>
{{ link_to('job/detail/' . $job->id. '/action', 'Finish Task', ['class' => 'btn btn-primary btn-lg']) }}
</p>
count` DESC LIMIT 4
答案 3 :(得分:0)
您必须尊重查询的语法......
这是不正确的:
SELECT * FROM post ORDER BY count DESC WHERE kategori="Batch" LIMIT 4
这个是正确的(从我在你的代码中看到的):
SELECT * FROM post WHERE kategori="Batch" ORDER BY count DESC LIMIT 4