Simple Search Bar With Php & Mysql



<html>

<title></title>

<head>

</head>



<body>

<fieldset>

<form action="" method="POST">

<center><h3> Check Result</h3></center>

<center>



Search<br>

<input type="text" name="rolld" >

<br><br>

<input type="text" name="dob">

<br><br>

<input type="submit" name="submit">

</center>

</form>

</fieldset>

</body>



</html>

<center>

<?php

error_reporting(0);

$conn = mysqli_connect("localhost", "root", "","schoolreult");



//search code

//error_reporting(0);

if($_REQUEST['submit']){

$name = $_POST['name'];

$result=$_POST['result'];

$rolld=$_POST['rolld'];

$fathername=$_POST['fathername'];

$dob=$_POST['dob'];

$marks=$_POST['marks'];

$subject1=$_POST['subjct1'];

if(empty(rolld)){

$make = '<h4>You must type a word to search!</h4>';

}else{

$make = '<h4>No match found!</h4>';

$sele = "SELECT * FROM result WHERE rolld LIKE '%$rolld%' AND dob='$dob'";

$result = mysqli_query($conn,$sele);



if($mak = mysqli_num_rows($result) > 0){

while($row = mysqli_fetch_assoc($result)){

echo '<h4> Id : '.$row['id'];

echo '<br> rolld : '.$row['rolld'];

echo '<br> name : '.$row['name'];

echo '<br> Fathername : '.$row['fathername'];

echo '<br> dob : '.$row['dob'];

echo '<br> marks : '.$row['marks'];



echo '<br> result : '.$row['result'];

echo '<br> subject1 : '.$row['subject1'];



echo '</h4>';

}

}else{

echo'<h2> Search Result</h2>';



print ($make);

}

mysqli_free_result($result);



}

}



?>

</center>
Previous
Next Post »
Thanks for your comment