0

is there anything wrong with this code? i seem to have 3 tables pelajar, bacaan, gurukelas and all the values are correct and i double checked them. I just want to have justification whether I code it correctly :)

$dataD = mysqli_query($hubung,"
    SELECT COUNT(pelajar.idpelajar) as bilang,
    pelajar.idpelajar,
    pelajar.nama,
    pelajar.jantina,
    gurukelas.kelas FROM pelajar
    INNER JOIN bacaan ON bacaan.idpelajar
    INNER JOIN gurukelas ON gurukelas.idguru
    GROUP BY bacaan.idpelajar
    ORDER BY bilang DESC
");
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    The join's in the `FROM` clause are incomplete. `ON bacaan.idpelagar = pelajar.idpelajar`, and the need the same for the `gurukelas` JOIN too. – Paul T. Jul 10 '20 at 12:43
  • Take a look at manual of `mysqli_query` https://www.php.net/manual/en/mysqli.query.php. It says "Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE." Since your warning is bool given and your query is a select, then it must be returning FALSE. Do `var_dump($dataD)` to confirm. Also check the logs for errors. Morever, what @PaulT. said is also valid. You miss JOIN condition, although that won't cause `mysqli_query` to return FALSE. – maresa Aug 21 '20 at 20:11

0 Answers0