入力ボックスの内容が変更されて送信されたときに、データベースが更新されるはずの入力ボックスでテーブルの内容を更新するはずのフォームを作成しました。 これが私の最初のページです:PHPを使ったMySQLのhtml形式の更新
<body>
<form action="qa1.php" method="post">
<ul>
<li><a class="active" href="df1.php">Disease</a></li>
<li><a href="drug.php" >Drug</a></li>
<li><a href="#about">Interaction</a></li>
<a href="#" class="dropbtn">Alternate Drug</a>
</ul>
<?php
$query = "SELECT * FROM disease;";
$result = mysqli_query($dp, $query);
echo "<table border=5>
<tr>
<th>Select</th>
<th>Edit</th>
<th>Disease ID</th>
<th>Disease</th>
<th>Sub Disease</th>
<th>Associated Disease</th>
<th>Ethinicity</th>
<th>Source</th>
</tr>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td><input type='radio' name='select' value=".$row['Disease_id']."/> </td>";
echo "<td>".$row{'Disease_id'}."</td>";
echo "<td><a href='edit.php?Disease_id=".$row['Disease_id']."'>edit</a></td>";
echo "<td>".$row{'Disease'}."</td>";
echo "<td>".$row{'SubDisease'}."</td>";
echo "<td>".$row{'Associated_Disease'}."</td>";
echo "<td>".$row{'Ethinicity'}."</td>";
echo "<td>".$row{'Source'}."</td>";
echo "</tr>";}
echo "</table>";
$selectedRow=$_POST['select'];
?>
<div>
<table border="0" align="center" style="border-spacing: 40px 30px;">
<caption><strong>QualityAnalysis:</br></br></strong></caption></br></br>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="4" WIDTH="40%">
</br><div><center>
<button style="color: red"><a href="adddf1.php" target="_self" name="Add" value="Add">Add</a></button>
<input type = 'submit' value = 'Delete' name = 'submitdelete' button style="color: red"></button>
<input type = 'submit' value = 'Update' name = 'submitupdate'>
</center></div> </TABLE>
</body>
</html>
は、これは私の編集ページです:个人设定
<body>
<form action="edit.php" method="post">
<ul>
<li><a class="active" href="df1.php">Disease</a></li>
<li><a href="drug.php" >Drug</a></li>
<li><a href="#about">Interaction</a></li>
<a href="#" class="dropbtn">Alternate Drug</a>
</ul>
<div>
<?php
$conn = mysqli_connect('localhost','root','','tool');
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_error());
}
if(isset($_GET['Disease_id']))
{
if(isset($_POST['Update']))
{
$id=$_GET['Disease_id'];
$name=$_POST['Ethinicity'];
$query3=mysqli_query("update disease set Ethinicity='$name', where Disease_id='$id'");
if($query3)
{
header('location:qa1.php');
}
}
$query1=mysqli_query("select * from disease where Disease_id='$id'");
$query2=mysqli_fetch_array($query1);
?>
<table border="2" align="center" style="border-spacing: 40px 30px;">
<caption><strong>Edit</br></br></strong></caption></br></br>
<tr>
<td>Ethinicity<input type="text" list="Ethinicity" name="Ethinicity" value="<?php echo $row['Ethinicity'];?>"/>
<input type="hidden" name="Disease_id" value="<?php echo $row['Disease_id']; ?>"/>
<input type="submit" name="Update" value ="Update">
<?php
}
?>
</center></div></div>
</form>
が、データがデータベースで更新取得されません。誰もこれで私を助けることができますか?
mysqli_queryは接続文字列として最初のパラメータが必要です!! http://php.net/manual/en/mysqli.query.phpを読んでください。 UPDATEクエリのwhere節より前の余分な '、' – Saty
更新クエリにエラーがあります。 '疾患の更新' Ethinicity = '$ name' Disease_id = '$ id'' – developersaumya
ありがとうございます。私はそれらの間違いを編集しました。それでもデータは更新されていません –