set_charset(‘utf8mb4’);
// Check for database connection errors
if ($conn->connect_error) {
die(‘Connection failed: ‘ . htmlspecialchars($conn->connect_error));
}
$result = null;
if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {
$grade = $conn->real_escape_string($_POST[‘grade’]);
$subject = $conn->real_escape_string($_POST[‘subject’]);
$chapter = $conn->real_escape_string($_POST[‘chapter’]);
$section = $conn->real_escape_string($_POST[‘section’]);
$sql = “SELECT * FROM topics WHERE grade=’$grade’ AND subject=’$subject’ AND chapter=’$chapter’ AND section=’$section'”;
$result = $conn->query($sql);
// Check for query execution errors
if (!$result) {
die(‘Query failed: ‘ . htmlspecialchars($conn->error));
}
} else {
// Fetch the last 20 posts
$sql = ‘SELECT * FROM topics ORDER BY created_at DESC LIMIT 20’;
$result = $conn->query($sql);
// Check for query execution errors
if (!$result) {
die(‘Query failed: ‘ . htmlspecialchars($conn->error));
}
}
?>
شروحات وحلول منهاج سلطنة عُمان المطور 2024
آخر 20 مشاركة
num_rows > 0) : ?>