0

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>";
        }
    }
}
Neil
  • 14,063
  • 3
  • 30
  • 51

1 Answers1

0

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>";        
    }
}
Peter
  • 16,453
  • 8
  • 51
  • 77