我的项目是关于过敏症,我正在尝试添加一张表中提供的过敏症"过敏症列表"到另一张桌子" MyAllergies"使用onclick按钮"添加"给予每种过敏。我想要的是当用户点击一个过敏的添加按钮时,特定的过敏应该自动添加到" MyAllergy.php"。请帮我。我已经尝试了2天,我没有在哪里。但是,我尝试了查询,几乎是正确的。我会非常感激的。谢谢。如果您希望我附上其他代码或更多问题,请与我们联系。 :)
AddAllergy.php
<?php
include('Session.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Allergen Details</title>
<div align="center">
<h1>Allergen Information</h1>
</div>
</head>
<body>
<?php
$allergysql = 'SELECT Allergy,Description,Symptoms FROM FoodAllergy';
$retrieve = mysqli_query($connection, $allergysql);
if(!$retrieve)
{
die("Could not get data!".mysqli_error($connection));
}
print "
<table border=\"5\" cellpadding=\"7\" style=\"border-collapse: collapse\" bordercolor=\"#85144b\" width=\"100%\" id=\"AutoNumber2\" bgcolor=\"#7FDBFF\"><tr>
<th width=100>Allergy:</th>
<th width=100>Description:</th>
<th width=100>Symptoms:</th>
<th width=100>Status:</th>
</tr>";
while($rowA = mysqli_fetch_assoc($retrieve))
{
print "<tr>";
print "<td>" . $rowA['Allergy'] . "</td>";
print "<td>" . $rowA['Description'] . "</td>";
print "<td>" . $rowA['Symptoms'] . "</td>"; ?>
<td> <div align ="center"> <button type ="button" onclick="addallergy()">Add</button></div></td>
<script>
function addallergy() {
// WHAT SHOULD I ADD HERE?? //
alert ('Added to your profile!');
}
</script>
<?php
print "</tr>";
}
print "</table>";
?>
</body>
</html>