我查询中的错误[重复]

Please help me with this code :

<?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>';
                }
            ?>

I had a php error with that code :

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /storage/ssd3/441/2169441/public_html/newennime/index.php on line 110

whats wrong with that code, please tell me how to fix it

Sorry for my bad english

</div>

WHERE clause will come first then ORDER BY and at any scenario LIMIT wil comes very last. Hoping this helps.

$query = "SELECT * FROM post WHERE kategori='Batch' ORDER BY count DESC LIMIT 4";

Order by should be after Where:

SELECT * FROM post WHERE kategori="Batch" ORDER BY count DESC LIMIT 4

'Order by' is before 'where' in the sql query. Also count is a mysqli function so needs to be inside . Should be SELECT * FROM post WHERE kategori="Batch" ORDER BYcount` DESC LIMIT 4

You have to respect the syntax of the query...

This is incorrect :

SELECT * FROM post ORDER BY count DESC WHERE kategori="Batch" LIMIT 4

This one is correct (from what I saw in your code) :

SELECT * FROM post WHERE kategori="Batch" ORDER BY count DESC LIMIT 4