Skip to content
Advertisement

Php flip the echo result

I confused the method to flip the place of the echo result, below is my code

while ($looptools == 0) {
    $mysqlihelper = " SELECT * FROM soal WHERE nomorsoal = $numberofmysqli ";
    $mysqliquery = mysqli_query($konek, $mysqlihelper);
    $resultquery = mysqli_fetch_assoc($mysqliquery);
    $resulttextjudul = $resultquery['judul'];
    if ($resulttextjudul == null) {
        unset($resulttextjudul);
        $resulttextjudul = "Tunggu Soal Berikutnya ! ..";
        $nullerror = true;
    } else {
    }
    if ($nullerror == true) {
        echo "<div class="head-main-recenttest-result" style="text-decoration:none">" . $resulttextjudul . "</div>";
    } else {
        echo "<a href="bacasoal.php"><div class="head-main-recenttest-result"  style="text-decoration:none">" . $resulttextjudul . "</div></a>";
    }
    if ($nullerror == true) {
        mysqli_close($konek);
        break;
    } elseif ($looptools == 10) {
        mysqli_close($konek);
        break;
    } else {
    }
}

As you see in the “while“, it’s echo the first result and the second result below it, but I want the first result in below of the second result, can anyone tell me the method to do it?

Advertisement

Answer

sorry if i answer my own question because i found it out myself

use mysqli_num_rows or often called mysqli count

http://php.net/manual/en/mysqli-result.num-rows.php

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement