php search sql

 <?php

include 'config.php';


// $method = $_SERVER["REQUEST_METHOD"] == "GET" ;


if (isset($_GET['submit'])) {

$query =  $_GET['s'];

$sql = "SELECT * FROM threads WHERE `thread_title` LIKE '%{$query}%'";

// $sql = " SELECT * FROM threads where preg_match('jhdhfjdfj', thread_title ";

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

$check = mysqli_num_rows($result);


if ($check) {

echo 'available<br>';

}

else

{

echo 'not found';

}


// $totalThreads = mysqli_num_rows($result);

while($rows = mysqli_fetch_array($result))

{

echo 'Thread Titile = '.$rows['thread_title'].'<br>';

echo 'thread Description = '.$rows['thread_desc'].'<br>';

echo '<br>';

}

}

?>



<!DOCTYPE html>

<html>

<head>

<title>Php Search By Kanha</title>

</head>

<body>



<pre>

<form action="" method="GET">

<input type="text" name="s"><br>

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

</form>

</pre>


</body>

</html>





Post a Comment

0 Comments