PHP приказ на податоци од табела

HTML

<html>
<head>
<title>Moja WEB strana</title>

<head>
<body>

<form action = "baza_prikaz.php" method = "GET">

Ime: <input type = "text" name = "ime" />
Prezime: <input type = "text" name = "prezime" />
Email: <input type = "text" name = "email" />

<input type = "submit" value="prikazi"/>
</form>

</body>
</html>

 

baza_prikaz.php

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "mojaDB";
// Kreiranje na konekcija
$conn = new mysqli($servername, $username, $password, $dbname);
// Proverka na konekcijata
if ($conn->connect_error) {
  die("Nema konekcija  " . $conn->connect_error);
}

$tabela="ucenici";

$ime=$_GET['ime'];
$prezime=$_GET['prezime'];
$email=$_GET['email'];

$sql = "SELECT * FROM $tabela WHERE trim(ime)='$ime' AND trim(prezime)='$prezime'";

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

while($row = $result->fetch_assoc())
{
echo "Prikaz na eden " . $ime . $prezime . $email;
echo "<br>";
}

$sql = "SELECT * FROM $tabela WHERE 1";

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


while($row = $result->fetch_assoc())
{
echo "<br>";
$ime=$row["ime"];
$prezime=$row['prezime'];
$email=$row['email'];

echo "Prikaz na site " . $ime ." ". $prezime ." ". $email;

}

$conn->close();
?>