我正在尝试打印一张包含学生推荐书的表格,我想打印出ID,标题,文字和学生ID,但是当点击" search_all"按钮,我被告知它无法获取mysqli,我不知道该怎么做。
<?php ("session.php"); ?>
<?php require_once("connect.php"); ?>
<?php include("header.php"); ?>
<html>
<body>
<!-- Page Content -->
<h1 class="page-header">Learning Journals
<small>- Admin Search</small>
</h1>
<h3>Search Learning Journals</h3>
<form name="membership_form" action= "<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" id="contactForm" method="post">
<label>Search Journals ID:</label>
<br>
<input type="text" name="journal_search">
<br>
<button type="submit" name ="search_all" class="btn btn-primary">All Journals</button>
</form>
<?php
if(isset($_POST["search_button"]))
{
//create the sql statement
$sql_all= "SELECT * FROM testimonials";
$result = mysqli_query($con,$sql_all);
while ($row = mysqli_fetch_assoc($result))
{
echo
"<h4>Testimonial ID:</h4>". $row["testimonial_ID"].
"<h4>Title:</h4> ". $row["testimonial_title"].
"<h4>Text:</h4> ". $row["testimonial_text"].
"<h4>Student ID:</h4>". $row["student_ID"].
"</br>";
}
mysqli_close($con);
}
include("footer.php");
?>
</body>
</html>