shruti Akki
shruti Akki

Reputation: 23

while displaying it is ignoring first row of table

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>";
        }
    }
}

Upvotes: 0

Views: 43

Answers (1)

Peter
Peter

Reputation: 16915

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>";        
    }
}

Upvotes: 0

Related Questions