0

I have problem with ID undefined in PHP table.

  <div class="header"> 
   <h2 style="font-family: Heebo;padding: 25px;">Blog posts lists</h2>
    </div>
    <?php $results = mysqli_query($db, "SELECT Title, Date FROM posts");?>
<table>
    <thead>
        <tr>
            <th>Title</th>
            <th>Date</th>
            <th colspan="2">Action</th>
        </tr>
    </thead>
    <form action="" method="post">
    <?php while ($row = mysqli_fetch_array($results)) { ?>
        <tr>    
            <td><input name='id' id='id' value='".$id."' type='hidden'></td>
            <td><?php echo $row['Title']; ?></td>
            <td><?php echo $row['Date']; ?></td>
            <td>
            <a href="edit.php?edit=<?php echo $row['id']; ?>" class="fa fa-pencil" </a>
            </td>
            <td>`enter code here`
              <a href="index.php?edit=<?php echo $row["id"]; ?>" class="fa fa-globe"</a>
            </td>
            <td> 
            <a href="configDB.php?id=<?php echo $row['id']; ?>" onclick="return confirm('Are you sure?')" class="fa fa-trash" </a>
            </td>
        </tr>
    <?php 
} ?>
</table>
</form>
</div>
</body>
</html>

No matter what I do id is not recognised not even in the url.

I've tried to add isset function, still nothing. ConfigDB is where querys are, and I have declared variable there $id=0; This ConfigDB is included into index.html file.

1 Answers1

1

Change

<?php $results = mysqli_query($db, "SELECT Title, Date FROM posts");?>

to

<?php $results = mysqli_query($db, "SELECT id, Title, Date FROM posts");?>
Pieter Steyn
  • 502
  • 4
  • 14