while displaying it is ignoring first row of table

48 Views Asked by At

It is ignoring first row of table. What am I doing wrong?

$sql = "SELECT * FROM combo1 group by id ";
$result = mysqli_query($link, $sql);

if ($result && mysqli_num_rows($result) > 0) {
    while($row = $result->fetch_assoc()) {
        echo "<center>";
        while($row = mysqli_fetch_array($result)){
            echo "<tr>";
            echo "<td>" . $row['column'] . "</td>";
            echo "<td>" . $row['type'] . "</td>";
            echo "<td>" . $row['value'] . "</td>";
        }
    }
}
1

There are 1 best solutions below

0
On

You have two loops

while($row = mysqli_fetch_array($result)){

use only one

edit:

$sql = "SELECT * FROM combo1 group by id ";
$result = mysqli_query($link, $sql);

if ($result && mysqli_num_rows($result) > 0) {
    while($row = $result->fetch_assoc()) {
        echo "<tr>";
        echo "<td>" . $row['column'] . "</td>";
        echo "<td>" . $row['type'] . "</td>";
        echo "<td>" . $row['value'] . "</td>";
        echo "</tr>";        
    }
}