php - Can't fetch multiple rows from table -
i'm making page needs display rows stored in table named 'events' in database named 'school'
the problem though i've multiple entries/rows in table, reason single row displayed when run page.
here's code-
<?php require("includes/common.php"); $query = "select * school.events"; $result = mysqli_query($con, $query)or die(mysqli_error($con)); $row = mysqli_fetch_array($result); $ename = $row['name']; $place = $row['place']; $date = $row['date']; ?> . . . <?php while ($row) { ?> <tr> <td><?php echo $date; ?></td> <td><?php echo $ename; ?></td> <td><?php echo $place; ?></td> </tr> <?php $row = mysqli_fetch_array($result); $name = $row['name']; $place = $row['place']; $date = $row['date']; } ?>
try instead while($row = mysqli_fetch_assoc($result)){ ... } , you're assigning array $row, can't loop array saying while($array)
do way:
while($row = mysqli_fetch_assoc($result)){ echo $row['id']; echo $row['name']; }
Comments
Post a Comment