27 lines
610 B
PHP
27 lines
610 B
PHP
<?php
|
|
$dbhost = "localhost";
|
|
$dbuser = "root";
|
|
$dbpass = "";
|
|
$dbname = "ocena_zachowania";
|
|
|
|
$con = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
|
|
|
|
if (!$con) {
|
|
die("Błąd połączenia z bazą danych: " . mysqli_connect_error());
|
|
}
|
|
|
|
if(isset($_GET['id_klasy'])) {
|
|
$id_klasy = intval($_GET['id_klasy']);
|
|
$ans = mysqli_query($con, "SELECT * FROM uczniowie WHERE id_klasy = $id_klasy;");
|
|
$json = array();
|
|
|
|
while($row = mysqli_fetch_assoc($ans)) {
|
|
$json[] = $row;
|
|
}
|
|
|
|
echo json_encode($json);
|
|
} else {
|
|
echo json_encode(array("error" => "Brak podanego ID klasy."));
|
|
}
|
|
?>
|