行的php mysql编辑按钮

8hhllhi2  于 2021-06-23  发布在  Mysql
关注(0)|答案(0)|浏览(227)

我被mysqli数据库中用php制作的edit/modify按钮卡住了。我不能让所有3行一起工作,唯一有效的是日期,其他的不修改,我甚至没有得到任何错误或东西。主键是 codr .
有什么线索吗?
这是index.php

<?php
include 'header.php';
?> 

<div class="head"></div>
<div class="cont">
<?php
$conn= mysqli_connect("localhost","root", "", "registration"); 
$sql="SELECT * FROM fiser";
$result=mysqli_query($conn, $sql);
$queryResults= mysqli_num_rows($result); 

if($queryResults > 0) {
while ($row = mysqli_fetch_assoc($result)) { echo" 
<table border=1 bgcolor=#b3ccff>
<tr>
    <th>Numarul fisei de retur</th>
    <th>Numarul comenzii</th> 
    <th>Data inregistrarii fisei de retur</th>
    <th>Motivul returului </th>
    <th colspan=2><center> Actiune </th>
</tr> 
<tr> 
<td><p> ".$row['codr']." </p> </td>
<td><p>  ".$row['codc']." </p> </td>
<td><p> " .$row['datar']." </p></td>
<td><p> " .$row['motivr']." </td>
<td><a href='edit.php?edit=$row[codr] '> edit </a> </td> 

</tr> "; }}  ?> 
</div>

这是edit.php

<?php

include('header.php') ;?>
<?php
if (isset($_GET['edit']))
{
    $codr=$_GET['edit'];
    $sql="SELECT * FROM fiser WHERE codr='$codr'";
    $res= mysqli_query($conn, $sql);
    $row= mysqli_fetch_array($res);
}
if(isset($_POST['newComanda']) && isset($_POST['newName']) && isset($_POST['newData']))
{
    $newName=$_POST['newName'];
    $newComanda=$_POST['newComanda'];
    $newData=$_POST['newData'];
    $codr=$_POST['codr'];
    $sql="UPDATE fiser SET codc='$newComanda' && motivr='$newName' && datar='$newData' WHERE codr='$codr'";
    $res=mysqli_query($conn,$sql) or die("Could not update".mysqli_error($conn));
    echo "<meta http-equiv='refresh' content='0;url=form.php'>";
}
?>

<form action="edit.php" method="POST">
Cod comanda : <input type="text" name="newComanda" value="<?php echo $row['codc']; ?>"><br>
Motiv : <input type="text" name="newName" value="<?php echo $row['motivr']; ?>"><br>
Data : <input type="date" name="newData" value="<?php echo $row['datar']; ?>"><br>
 <input type="hidden" name="codr" value="<?php echo $row[0]; ?>">
<input type="submit" value="Update"> 
</form>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题