我有一个连接到数据库的Android应用程序,可以更新相关数据,然后以表格的形式显示到网站,我想要做的只是当某个按钮是某个按钮时显示某些数据单击应用程序,单击其他按钮时的不同数据。这可能吗?我已经在下面包含了Java OnClick方法以及用于连接和显示所有数据的PHP / MySQL代码。因此,当点击OpenUpdateBed1时,我希望它只在床1上显示数据,当点击OpenUpdateBed2时,它应该从网站上删除床1的数据并显示床2的数据。为了我自己的隐私,PHP留空了,它们并没有引起问题。
public void OpenUpdateBed1 (View view){
startActivity(new Intent(this, Register.class));
}
public void OpenUpdateBed2(View view){
startActivity(new Intent(this, Register2.class));
}
<?php
$servername = "";
$username = "";
$password = "";
$database = "";
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$conn = new mysqli($servername, $username, $password, $database);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($db, "SELECT * FROM patients2");
echo "<table border = 5>";
echo "<tr>";
echo "<th>ID</th>
<th>Patient name</th>
<th>Doctor name</th>
<th>Check in date</th>
<th>Room number</th>
<th>Bed number</th>
<th>Notes</th>
<th>Time</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['patient_name'] . "</td>";
echo "<td>" . $row['doctor_name'] . "</td>";
echo "<td>" . $row['check_in_date'] . "</td>";
echo "<td>" . $row['room_number'] . "</td>";
echo "<td>" . $row['bed_number'] . "</td>";
echo "<td>" . $row['notes'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($db);
?>