Kingston_Pendrive/Suli/13.b/Backend/2024. 11. 25/index.php
2024-12-02 14:37:26 +01:00

54 lines
1.6 KiB
PHP

<?php
require_once("config.php");
if (isset($_POST["cim"])) {
$cim = $_POST["cim"];
$tip = $_POST["tipus"];
$ar = $_POST["jegyar"];
$parsql = "INSERT INTO film (cim, filmtipusID, jegyar) VALUES (?, ?, ?)";
$durr = $conn -> prepare($parsql);
$durr -> bind_param("sii", $cim, $tip, $ar);
if ($durr -> execute() == true) {
echo "<b>Sikeres adatbevitel<b>";
}
}
else {
if (isset($_POST["szures"])) {
$felt = $_POST["szures"];
$sql = "SELECT cim, jegyar FROM film WHERE cim LIKE '%".$felt."%' ORDER BY cim ";
$sqlparam = $conn -> prepare("SELECT cim, jegyar FROM film WHERE cim LIKE ? ORDER BY cim ");
$sqlparam -> bind_param("s", $felt);
$sqlparam -> execute();
// $result = $conn -> query($sql);
$result = $sqlparam -> get_result();
if ($result -> num_rows > 0) {
$i = 1;
echo "<table>
<tr><th>Ssz.</th>
<th>Cím.</th>
<th>Ár.</th>
<tr>";
while ($row = $result -> fetch_object()) {
echo "<tr>
<td>".$i++."</td>
<td>".$row -> cim."</td>
<td>".$row -> jegyar."</td>
</tr>";
}
echo "</table>";
}
}
else {
echo "Nincs adat";
}
require_once("html.php");
$conn -> close();
}
?>