下面我有一个成功工作的 mysqli 查询;
$courseid = (isset($_POST['courses'])) ? $_POST['courses'] : '';
$moduleid = (isset($_POST['moduleid'])) ? $_POST['moduleid'] : '';
$moduleno = (isset($_POST['moduleno'])) ? $_POST['moduleno'] : '';
$modulename = (isset($_POST['modulename'])) ? $_POST['modulename'] : '';
$query = "SELECT cm.CourseId, CourseNo, CourseName, cm.ModuleId
FROM Course c
INNER JOIN Course_Module cm
ON
c.CourseId = cm.CourseId
JOIN Module m
ON
cm.ModuleId = m.ModuleId
WHERE cm.CourseId = ? AND cm.ModuleId = ?";
// prepare query
$stmt=$mysqli->prepare($query);
// You only need to call bind_param once
$stmt->bind_param("ii", $courseid, $moduleid);
// execute query
$stmt->execute();
// get result and assign variables (prefix with db)
$stmt->bind_result($dbCourseId, $dbCourseNo, $dbCourseName, $dbModuleId);
//get number of rows
$stmt->store_result();
$numrows = $stmt->num_rows();
我遇到的问题是在我的成功消息中。它能够输出$moduleno
and$modulename
变量,但它不会在成功消息中输出$dbCourseNo
and变量。$dbCourseName
为什么是这样?
if ($numrows == 1){
echo "<span style='color: green'>The following Module has been added into Course:" . $dbCourseNo . " - " . $dbCourseName . ":<br/>" . $moduleno . " - " . $modulename . "</span>";
}