I would like to seek assistance with the problem I'm facing now. I have a master page (master.php) with the following code.
<html>
<head>
<meta charset="UTF-8">
<title>Master Page</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<!--Header -->
<div class="jumbotron text-center" style="margin-bottom:0">
<h3>Kiribati Infrastructure Database System</h3>
</div>
<!--Main Menu -->
<!--Main Content -->
<div><?php echo $content;?></div>
<!--Footer -->
<div class="jumbotron text-center" style="margin-bottom:0">
<p>Footer</p>
</div>
</body>
</html>
Every php-page will have the following php codings
<?php
$content = '';
include('master.php');
?>
The problem I'm facing now is that I can't display other php-pages to get in that variable.
For example, I want to display the result of this codings and put it inside $content variable but I don't know how. I would appreciate any assistance provided for this project.
<body>
<div class="container">
<h2>Gender Report:</h2>
<p></p>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Gender</th>
</tr>
</thead>
<tbody>
<?php
// Provide the file for username, password and database name
require_once 'mysqlconn.php';
$conn = new mysqli($hostname, $username, $password, $database);
if ($conn->connect_error) {
die("Connection failed:" . $conn->connect_error);
}
$sql = "SELECT * FROM tbl_gender";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc())
{
echo "<tr>";
echo "<td>" . $row['gender_id'] . "</td>";
echo "<td>" . $row['gender_description'] . "</td>";
echo "</tr>";
}
} else {
echo "0 results";
}
$conn->close();
//include('master.php');
?>
</tbody>
</table>
</div>
</body>