<?php
function get_subject_by_id2() {
global $connection;
$query = "SELECT * ";
$query .= "FROM subjects ";
$query .= "WHERE id= 2 ";
$query .= "LIMIT 1";
$result_set = mysqli_query($connection, $query);
confirm_query($result_set);
// REMEMBER:
// if no rows are returned, fetch_array will return false
if ($subject = mysqli_fetch_array($result_set)) {
return $subject2;
} else {
return NULL;
}
}
echo $subject2['content1'];
echo $subject2['content2'];
?>
我不知道为什么这不起作用。请帮忙!
我相信它不会返回NULL,而是返回$ subject2。出于某种原因,它不起作用。