<?php 
    require_once('config.php');

    if (isset($_POST["cim"])){
        $cim = $_POST["cim"];
        $tip = $_POST["tipus"];
        $ar = $_POST["ar"];

        $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 feltöltés</b>';
        }
    }

    if (isset($_POST["szures"]))
    {
        
        $felt = $_POST["szures"];
        $sql = "Select cim,jegyar FROM film WHERE cim like '%".$felt."%' order by cim";

    $result = $conn->query($sql);

    //paraméteres sql lekérdezés
    $felt = "'%.$felt.%'";
    $sqlparam = $conn->prepare("Select cim,jegyar FROM film WHERE cim like ? order by cim");
    $sqlparam->bind_param("s", $felt);
    $sqlparam->execute();
    $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();
?>