PHP ID未定义
PHP ID undefined
我对 PHP table 中未定义的 ID 有疑问。
<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>
无论我做什么id 都不被识别甚至在url。
我试过添加isset功能,还是不行。
ConfigDB 是查询所在的地方,我在那里声明了变量 $id=0;
此 ConfigDB 包含在 index.html 文件中。
改变
<?php $results = mysqli_query($db, "SELECT Title, Date FROM posts");?>
至
<?php $results = mysqli_query($db, "SELECT id, Title, Date FROM posts");?>
我对 PHP table 中未定义的 ID 有疑问。
<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>
无论我做什么id 都不被识别甚至在url。
我试过添加isset功能,还是不行。 ConfigDB 是查询所在的地方,我在那里声明了变量 $id=0; 此 ConfigDB 包含在 index.html 文件中。
改变
<?php $results = mysqli_query($db, "SELECT Title, Date FROM posts");?>
至
<?php $results = mysqli_query($db, "SELECT id, Title, Date FROM posts");?>