내가 3 개 VARCHAR 필드 간단한 테이블을 읽고 지금까지이 코드를 가지고 업데이트하는 업데이트 SQL 문을 작성하는 :방법은 여러 레코드
<?php
//db connection code...
// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$query = "SELECT * FROM Sheet1";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "<html><body><table cellpadding=10 border=1>";
while($row = mysql_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$row['stickerID']."</td>";
echo "<td>" .$row['stickerName']."</td>";
echo "<td>".$row['stickerSection']."</td>";
echo "<td>"?>
<form name="some form" action="editform.php" method="post">
<input type="checkbox" name="<?php echo $row['stickerID'] ?>" value=" <?php echo $row['stickerStatus'] ?> ">
<?php "</td>";
echo "</tr>";
}
echo "</table></body></html>";
echo " " ?>
<input type="submit" name="editWish" value="Edit">
</form>
<?php " ";
} else {
// no
// print status message
echo "No rows found!";
}
// free result set memory
mysql_free_result($result);
// close connection
mysql_close($connection);
?>
데이터베이스는 4 개 필드 3 VARCHAR 및 1 개 INT와있다 현재 값은 0입니다. 페이지 소스 코드를 확인하고 각 확인란 이름이 stickerID인지 확인했습니다. 이제 나는 이것을 만들어야하는 editform.php에 게시 할 것입니다. 임 궁금 무엇을 계정으로 양식에있는 사용자가 선택한 각 새 값을 계정으로 걸릴 수 있도록 SQL 업데이트를 작성해야합니까?
이것은 제 생각이지만 모든 확인란마다 어떻게해야합니까?
editform.php
<?php
//update multiple records
//UPDATE user_items SET stickerStatus = $_POST["stickerStatus"] WHERE stickerID = $_POST["stickerID"];
?>
과 부울 거짓 aswell을 의미 할 수있다, 테이블의 중간에하고있는