-1

Good Day! Im having a problem displaying the data from table. I have already inputted 6 data and it will show how many base from my $i++ but it does not show the userno, fullname and udate. i would really appreciate it Please and thank you! Table Display Here is my code:

table class="table table-striped table-sm">
  <thead>
    <tr>
      <th>No</th>
      <th>User No</th>
      <th>User Name</th>
      <th>Date Registered</th>
    </tr>
  </thead>
  <tbody>

    <?php
      $i=0;
      $uquery= mysqli_query($conn, "SELECT * FROM users");
      while ($uresult=mysqli_fetch_array($uquery)){

      $i++;  
    ?>
      <tr>
        <td><?php echo $i;?></td>
        <td><?php $uresult ['userno'];?></td>
        <td><?php $uresult ['fullname'];?></td>
        <td><?php $uresult ['udate'];?></td>

    <?php }; ?> 
  </tbody>
</table>
Mavreen
  • 21
  • 3

3 Answers3

1

You forgot to echo your results.

Change

<td><?php $uresult ['userno'];?></td>
<td><?php $uresult ['fullname'];?></td>
<td><?php $uresult ['udate'];?></td>

To

<td><?php echo $uresult ['userno'];?></td>
<td><?php echo $uresult ['fullname'];?></td>
<td><?php echo $uresult ['udate'];?></td>

Or

<td><?= $uresult ['userno'];?></td>
<td><?= $uresult ['fullname'];?></td>
<td><?= $uresult ['udate'];?></td>
Stefmachine
  • 382
  • 4
  • 11
0

First of all, you have missed end</tr>, second do you really have to use variable i and increment it? where you can echo all ID? and why there's semi-colon after your closing bracket.Lastly, you should have put echo in variables uresult Hope this could help you

<table class="table table-striped table-sm">
<thead>
<tr>
  <th>No</th>
  <th>User No</th>
  <th>User Name</th>
  <th>Date Registered</th>
</tr>
</thead>
<tbody>

<?php
  $uquery= mysqli_query($conn, "SELECT * FROM users");
  while ($uresult=mysqli_fetch_array($uquery)){
?>
  <tr>
    <td><?php echo $uresult ['id'];?></td>
    <td><?php echo $uresult ['userno'];?></td>
    <td><?php echo $uresult ['fullname'];?></td>
    <td><?php echo $uresult ['udate'];?></td>
  </tr>
<?php } ?> 
</tbody>
</table>




and also you can write it, in this way:
and echo variable `i` if you want to see the count of it.
<?php
  $uquery= "SELECT * from users";
  $viewquery = mysqli_query($con,$uquery);
  while($uresult = mysqli_fetch_assoc($viewquery))
{
?>
Jaz
  • 55
  • 8
0
$sql = "SELECT userno, fullname, udate FROM users";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
            echo "<br> userno: ". $row["userno"]. " - Full Name: ". $row["fullname"]. " - udate: " . $row["udate"] . "<br>";
}
} else {
    echo "0 results";
}
//Don't Forget To:
$conn->close();

This'll be your PHP, adjust it accordingly to your table, hope this helps!

Da Mahdi03
  • 1,468
  • 1
  • 9
  • 18