doumao1519 2018-09-06 01:00
浏览 20

PHP,如何显示第二个表

DBOperations.php

public function getByQRID($id){
    $stmt = $this->conn->prepare("SELECT students.*, courses.* FROM students INNER JOIN courses ON courses.id = students.course_id WHERE students.id = ?");
    $stmt->bind_param("s", $id);
    $stmt->execute();
    return $stmt->get_result()->fetch_assoc();
}

Update the code

  • 写回答

1条回答 默认 最新

  • douqi1928 2018-09-06 01:25
    关注

    If you are you using MySql, then try this:

    select * from Student 
    inner join Course on Student.course_id = Course.id
    where Student.id = 1
    

    (1 it's an example, and I'm guessing things, since your question wasn't entirely clear).

    I hope it helps!

    评论

报告相同问题?