内部联接 &按 id 用户 API 显示数据



如何显示学生价值数据?因此,对于访问,父母只能看到孩子的价值数据。请帮助

方案

对于标题,我已将其放在conn.php文件中

<?php
require_once "conn.php";
$query = "SELECT student, name, payment FROM payment INNER JOIN parent ON payment. student_id = student. student_id WHERE student. parent_id = id login parent" ;
$sql = mysqli_query ($link,$query);
$ray = array();
while ($row = mysqli_fetch_array($sql)) {
array_push($ray, array(
"id" => $row['id'],
"student_id" => $row['student_id'],
"date" => $row['date'],
"grade" => $row['grade']
));
}
echo json_encode($ray);
mysqli_close($link);
?>

函数.php

<?php
function escape($data){
global $link;
return mysqli_real_escape_string($link, $data);
}

function username_check($username){
global $link;
$query = "SELECT * FROM parent WHERE username='$username'";
$result = mysqli_query($link, $query);
if(mysqli_num_rows($result) == 0 ) return true;
else return false;
}

function email_check($email){
global $link;
$query = "SELECT * FROM parent WHERE email='$email'";
$result = mysqli_query($link, $query);
if(mysqli_num_rows($result) == 0 ) return true;
else return false;
}
?>

我很困惑,因为我刚刚了解到这一点以及错误的结果;D

我想你需要这样的

SELECT
m.grade,
m.subject,
m.date,
s.name
FROM mark m
INNER JOIN student s ON m.student_id = s.id
INNER JOIN parent p on s.parent_id = p.id
WHERE
p.id = *parent id*

相关内容

  • 没有找到相关文章