我已经创建了一个PHP函数来显示来自数据库的数据,
我想把它包含在我的megento2块函数中,
这是我选择数据的代码
$dates = date("Y-m-d");
$phone = $_POST["phone"];
$sql = "SELECT * FROM otpp WHERE phone = '$phone' AND dates = '$dates'";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
// if exists ?
if ($count > 0) {
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$otppass = $row["otp"];
echo $otppass;
} else {
echo "0 results";
}
Run Code Online (Sandbox Code Playgroud)
我是否可以继续这种方式从数据库或任何其他方式获取数据来使用数据库中的数据?
我正在尝试使用 javascript 上的 GET 方法从 URL 获取数据,
fetch('/api/staffattendance/{makedate}')
.then(res => res.json())
.then(res => {
//this.staffs = res.data;
console.log(res.data);
})
.catch(err => console.log(err));
Run Code Online (Sandbox Code Playgroud)
我如何在这里传递变量:
fetch('/api/staffattendance/{makedate}')
Run Code Online (Sandbox Code Playgroud)
像这样
提前致谢,