有一张包含客户数据的表格。试图合并编辑功能。目前,该表格中包含<a href>
“编辑”链接。
<tr>
<th><strong>Extras</strong></th>
</tr>
<?php while($r = mysqli_fetch_assoc($res)){
?>
<tr>
<td><a href="crud/update.php?id='.$r['id'].'">Edit</a></td>
<td><input type="button" onClick="deleteme(<?php echo $r['u_uid']; ?>)" name="Delete" value="Delete"></td>
</tr>
function deleteme(delid)
{ if(confirm("Are you sure you want to Delete?")){
window.location.href='crud/delete.php';
}
}
</script>
<?php } ?>
请注意:
$ReadSql = "SELECT * FROM `contact` WHERE users_id=$uid ORDER BY Name";
$res = mysqli_query($connection, $ReadSql);
我希望将用户带到crud / update.php,它以:
开头<?php
error_reporting();
require_once('connect.php');
$id = $_GET['id'];
$SelSql = "SELECT * FROM `contact` WHERE id=$id";
$res = mysqli_query($connection, $SelSql);
$r = mysqli_fetch_assoc($res);
if(isset($_POST) & !empty($_POST)){
$name = mysqli_real_escape_string($connection,$_POST['name']);
//and other credentials
$UpdateSql = "UPDATE `contact` SET Name='$name', Company='$comp',
Title='$title', Phone='$phone', Email='$email', Address='$location' WHERE id=$id";
拔出我的头发,因为我无法找到每次按“编辑”链接时出错的原因。
干杯队员。
答案 0 :(得分:1)
您获得404的原因是您没有正确的链接。
您已在线上混合使用HTML和PHP
<a href="crud/update.php?id='.$r['id'].'">Edit</a>
应该是:
<a href="crud/update.php?id=<?php echo $r['id'] ?>">Edit</a>