나는 테이블을 가지고 있는데 그 테이블에 Status라는 컬럼이 있습니다. 상태 열에서 두 개의 라디오 버튼이 나란히 있고 준비가되어 있지 않습니다. 이제는 라디오 버튼에서 각 행의 값 하나를 가져 와서 값을 데이터베이스에 저장하려고합니다. 그러나 첫 번째 행의 라디오 버튼 값만 캡처 한 다음 값을 모든 행에 복사하고 데이터베이스에 저장합니다. ...PHP의 라디오 버튼에서 값을 가져 오는 방법
<?php
session_start();
$myDate = date('m/d/Y');
$servername = "localhost";
$username = "root";
$password = "[email protected]";
$dbname = "testbad_information";
$date = date("m/d/Y");
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$sql4 = "SELECT * FROM data WHERE `Date` = '".$myDate."' ORDER BY id DESC";
$reviewer = $_POST['reviewer'];
$status = $_POST['status'];
$query = $conn->query($sql4);
if($query->num_rows > 0){
while($row = $query->fetch_assoc()){
//...insert into your DB.
$row1 = $row["Date"];
$row2 = $row["Time"];
$row3 = $row["Alias"];
$row4 = $row["Machine_Name"];
$row5 = $row["Build_Name"];
$row6 = $row['Build_Version'];
$row7 = $row["WinDBG"];
$row8 = $row[".NET_Framework"];
$sql5 = "INSERT INTO history (`Date`, `Time`, `Alias`, `Machine_Name`, `Build_Name`, `Build_version`, `WinDBG`, `.NET_Framework`, `Status`, `Reviewed_By`)
VALUES ('".$row1."','".$row2."','".$row3."','".$row4."','".$row5."','".$row6."','".$row7."','".$row8."','".$status."','".$reviewer."') ";
if ($conn->query($sql5) === TRUE) {
//echo "New record created successfully";
//echo nl2br("\n");
echo "";
} else {
echo "Error: " . $sql5 . "<br>" . $conn->error;
}
}
}
include 'popupmessage.html';
?>
제발 도와주세요! :
<form action = "submit_varification.php" method = "POST" onclick = "return validate()">
<div style="position: absolute; left: 50px; top: 90px;">
<label class="right"><font color="white">Date:</font></label>
<input type="text" id = "frmDate" /><br>
<p id="date"></p>
</div>
<div style="position: absolute; left: 250px; top: 91px;">
<label class="right"><font color="white">V-ID:</font></label>
<input type="text" id = "myText" name = "reviewer" value = ""/><br>
</div>
<div style="position: absolute; left: 900px; top: 91px;">
<button type="button" name="show" id="show" onclick = "" >History</button>
</div>
<div style="position: absolute; left: 900px;">
<input type="submit" name="test" id="test" value="Submit" /><br/>
</div>
<script>
var date = new Date();
document.getElementById("frmDate").value = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();
</script>
</body>
<table style="position: absolute; width:95%; left: 20px; top: 150px;" id = "table1">
<?php
$myDate = date('m/d/Y');
?>
<tr>
<th>Date</th>
<th>Time</th>
<th>Alias</th>
<th>Machine_Name</th>
<th>Build_Name</th>
<th>Build_version</th>
<th>WinDBG</th>
<th>.Net_Framework</th>
<th>Status</th>
</tr>
<?php
//get records from database
$sql3 = "SELECT * FROM data WHERE `Date` = '".$myDate."' ORDER BY id DESC";
$query = $conn->query($sql3);
if($query->num_rows > 0){
while($row = $query->fetch_assoc()){ ?>
<tr>
<td><?php echo $row['Date']; ?></td>
<td><?php echo $row['Time']; ?></td>
<td><?php echo $row['Alias']; ?></td>
<td><?php echo $row['Machine_Name']; ?></td>
<td><?php echo $row['Build_Name']; ?></td>
<td><?php echo $row['Build_Version']; ?></td>
<td><?php echo $row['WinDBG']; ?></td>
<td><?php echo $row['.NET_Framework']; ?></td>
<td style='white-space: nowrap'><form><label class = "ready"><input type="radio" name="status" value = "Ready">Ready</label><label class = "notready"><input type="radio" name="status" value = "Not Ready" >Not Ready</label></form></td>
</tr>
<?php } } ?>
</table>
</form>
PHP 코드 : 아래
HTML 코드 .. 내가 가지고있는 코드입니다 각각의 행에 대한 상태를 저장하려고합니다. Like row1 | 준비 row2 | 준비 안 됨 하지만 이제는 모든 행에 똑같이 주어졌습니다.
어떤 디버깅을 했습니까? 사이드 노트 * - 당신은 SQL 삽입 –
에 열려 있습니다 [PHP에서 라디오 버튼 값을 보내는 방법] (https://stackoverflow.com/questions/14747803/how-to-send-radio-button- value-in-php) –