-2
感謝合作,大家對這個偉大的網站,這是我第二次問一個問題,我希望這不是我的工作我的項目太多了^^ ,和我有那種我更新頁面, 它基本上從表中顯示的所有數據在MySQL中,當我複選框,兩行用新信息更新一個奇怪的問題,它直接複製所有新信息「(最後僅排)」並將其全部複製到其他行,結果是,所有行變得完全相同!難道我做錯了什麼 ?請幫我的傢伙,這是我的代碼..更新頁面不會
我還當我嘗試更新任何其他行,它不會更新,但只更新了最後一排...
<?php
session_start();
if(isset($_SESSION['username'])){
include('../CIEcon.php');
echo "<form action= 'adminCleaning.php' method = 'post'>" ;
if(isset($_POST['update'])){
if(isset($_POST['id'])){
if(empty($_POST['id']) || $_POST['id'] == 0){
echo"<h4> please choose something to delete </h4>";
}else{
echo $implid = implode("' , '", $_POST['id']);
$sqlUpdate = "UPDATE Cleaning SET JobName= '$_POST[jobname]',Description= '$_POST[description]',NoStudent='$_POST[nostudent]',DueDate='$_POST[duedate]' WHERE Id IN('" . $implid . "')";
$resultUpdate = mysqli_query($dbCIE,$sqlUpdate)or die(mysqli_error($dbCIE));
if (mysqli_affected_rows($dbCIE) > 0) {
echo "You have successfully updated your data.<br><br>";
}
else {
echo "The data you submitted matched the current data so nothing was changed.<br><br>";
}
} // end of else..
} // end of if isset($_POST['id']) ...
} // end of if isset($_POST['update']) ...
$sql = "SELECT * FROM Cleaning ";
$result = mysqli_query($dbCIE, $sql) or die(mysqli_error($dbCIE));
/// NOW DISPLAY ALL INFO FROM CHOSEN DATABASE...
echo "
<table cellpadding ='4' border='1' width='80%' align='center'>
<tr>
<th class='tt' >Check </th>
<th class='tt'> Job's Name</th>
<th class='tt' >Description</th>
<th class='tt' > No Students needed</th>
<th class='tt' >Due Date</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<br>";
echo "<tr>";
echo "<td> <input type='checkbox' name='id[]' value='". $row['Id'] ."' /> </td>"; // array[] cause to edit more than one record...
echo "<td><input type='text' name='jobname' value='" . $row['JobName'] . "'> </td>";
echo "<td><input type='text' name='description' value='" . $row['Description'] . "'> </td>";
echo "<td><input type='text' name='nostudent' value='" . $row['NoStudent'] . "'> </td>";
echo "<td><input type='text' name='duedate' value='" . $row['DueDate'] . "'> </td>";
echo "</tr>";
}
echo "</table>";
/// END THE SEARCH HERE...........
echo " <br>
<div align='center'>
<input type='reset' value='clear' />
<input type='submit' name='update' value='update' />
</div> ";
mysqli_close($dbCIE);
echo "</form>";
}
else{echo "must logout to see this page..!!";}
?>
<html>
<head><title> ..Cleanding.... </title></head>
<style type="text/css">
body{
margin-top: 70px; /*space above the table....*/
background-color: #23438e;
}
table{
background-color: white;
}
.tt{
background: #f26822;
color: white ;
}
</style>
<body>
<!-- <a href= "../AdminIndex.php" > <button> Main Page </button></a> -->
</body>
</html>
你缺少收盤']''中的名稱= '的工作名[。 「$行[ '身份證'。」''。應該是'name =「的工作名[。‘$行[‘身份證’。’]」' – Sean
感謝你們,但它給了我一個錯誤,他們的方式ü沒有它.. – aymanko