27 lines
528 B
PHP
27 lines
528 B
PHP
|
<?php
|
||
|
$host = "localhost";
|
||
|
$user = "root";
|
||
|
$password = "";
|
||
|
$database = "samochody";
|
||
|
|
||
|
$conn = new mysqli($host, $user, $password, $database);
|
||
|
|
||
|
if ($conn->connect_error) {
|
||
|
die("Connection failed: " . $conn->connect_error);
|
||
|
}
|
||
|
|
||
|
$sql = "SELECT * FROM paliwa";
|
||
|
$result = $conn->query($sql);
|
||
|
|
||
|
$data = [];
|
||
|
if ($result->num_rows > 0) {
|
||
|
while ($row = $result->fetch_assoc()) {
|
||
|
$data[] = $row;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
header('Content-Type: application/json');
|
||
|
echo json_encode($data);
|
||
|
|
||
|
$conn->close();
|
||
|
?>
|