SELECT clients.FirstName, Clients.LastName, apointments.ApointmentDate, apointments.ApointmentTime from clients inner join Apointments on clients.ApointmentRef=Apointments.ApointmentRef where clients.apointmentref=3
这基本上是我正在使用的声明,而不是3,让用户输入和编号并返回结果这是我尝试过的:
用户输入值:
<input id="apointment" name="apointment">
function _(x){
return document.getElementById(x);
}
function submitdata(){
apointment = _("apointment").value;
_("multiphase").method = "post";
_("multiphase").action = "submitdata.php";
_("multiphase").submit();
_("phase8").style.display="none";
_("phase9").style.display="none";
_("phase10").style.display="none";
_("phase11").style.display="none";
_("phase12").style.display="none";
_("finalphase").style.display="block";
}
我在submitdata.php中的代码如下:
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$Address = $_POST['Address'];
$PhoneNumber = $_POST['PhoneNumber'];
$HomePhone = $_POST['HomePhone'];
$email = $_POST['email'];
$Comments = $_POST['Comments'];
$NaturalHairColour = $_POST['NaturalHairColour'];
$OtherDetails = $_POST['OtherDetails'];
$ApointmentRef = $_POST['Apointment'];
$apointment = $GET['apointment'];
$sql = "INSERT INTO clients (ApointmentRef, FirstName, lastname, address, PhoneNumber, HomePhone, email, Comments, NaturalHairColour, OtherDetails)
VALUES ('$ApointmentRef','$FirstName', '$LastName', '$Address', '$PhoneNumber', '$HomePhone', '$email', '$Comments', '$NaturalHairColour', '$OtherDetails')";
if ($conn->query($sql) === TRUE) {
$sql2= "SELECT clients.FirstName, Clients.LastName, apointments.ApointmentDate, apointments.ApointmentTime from clients where clients.apointmentRef='$apointment' inner join Apointments on clients.ApointmentRef=Apointments.ApointmentRef whereclients.apointmentref";
$result = $conn->query($sql2);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "First Name: " . $row["FirstName"]."Last Name: " . $row["LastName"]." Apointment Date: " . $row["ApointmentDate"]. " Appointment Time: " . $row["ApointmentTime"]. "<br>";
}
} else {
echo "0 results";
}
} else {
echo "Error: Apointment Unavailable, Please select another Slot" ;
}
$conn->close();
?>