This is a tutorial which goes over how to create a PHP search which filters out results from a database table. Sorry for the mistakes made in this video, the video …
Original source
Creating a PHP Search
custom, free, Helping develop, helpingdevelop, html, Joe, Make, mysql, mysql tutorial, php, php search, Search, Smith, source, tutor, tutorial
30 responses to “Creating a PHP Search”
It was good and how can i make a dictionary in php ?
Hello, Mr. Smith.
You can explain very clear php possibilities. Your example works with me very stable with a few moderations. Can you explain how to grab data from table generated after search and use it for example to insert in another table?
Why its search form does not appear after I created the code you share, whats wrong can you help me ?
This guy used 2 if statements but only one else statement…this is wrong…
I like this guy! You are awesome !
this is some alien shit bruh!
mysql commands are now deprecated, use 'mysqli'! you may follow this in case you're using php 5.6 or later.
# Is not a pound symbol
<?php
mysql_connect("localhost","root" ,"admin")or die ("could not connect");
mysql_select_db("sentmentanalysis" )or die ("could not find db");
$output= '' ;
if(isset($_POST['seach'])){
$searchq = $_POST['seach'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = mysql_query("SELECT * FROM post WHERE Title LIKE '%$$searchq%'OR Contect LIKE '%$searchq%'") or die ("could not search");
$count = mysql_affected_rows($query);
if ($count ==0){
$output = 'There was no search results' ;
}else{
while ($row = mysql_fetch_array($query)){
$titel = $row['Title'];
$contect = $row['Contect'];
$output = '<div>'.$titel.' '.$contect.'</div>';
}
}
}
?>
<html>
<head>
<title>Search</title>
</head>
<body>
<form action = "searchHtml.php" method="post">
<input type="text" name = "search" placeholder = "search …."/>
<input type="submit" value="OK"/>
</form>
<?php echo $output ;?>
</body>
</html>
—–
no result for this code ? whay
PLEASE HELP! ive encoutererd this kind of problem
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:wampwwwLibrary System Devb_general_knowledge.php on line 100
//this are my codes
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "library";
if(isset($_POST['search']))
{
$valueToSearch = $_POST['valueToSearch'];
$query = "SELECT * FROM `b_general_knowledge` WHERE CONCAT(`id`, `title`, `author`, `ISBN`, `accession_number`, `books_availability`)LIKE '%".$valueToSearch."%'";
$search_result = filtertable($query);
}
else
{
$query = "SELECT * FROM 'b_general_knowledge'";
$search_result = filtertable($query);
}
function filtertable($query)
{
$connect = mysqli_connect("localhost", "root", "", "library");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title> General Knowledge </title>
<!– Link in Css –>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/background.css" rel="stylesheet"></link>
</head>
<body>
<!
header><div align="center" class="page-header">
<h1><strong>SAINT PAUL UNIVERSITY DUMAGUETE</strong></h1>
<h1><small>COLLEGE LIBRARY</small></h1>
<br>
</br>
</head>
<body>
<!– heading for categories –>
<div class="panel panel-success" style="background-color:rgb(200,200,200);">
<h3 align="center" style="font-family:century;">
<h3><b>General Knowledge</b></h3>
</div>
<!– Searching –>
<div class="col-lg-3" style="padding-right: 10px;">
<div class="input-group">
<form action="b_general_knowledge.php" method="post">
<span class="input-group-btn" style="align-content: center;">
<input type="text" name="valueToSearch" class="form-control" placeholder="Search Information Of Books Here">
<input type="submit" name="search" class="btn btn-info" value="Search">
<br><br>
<a href="student_borrow_book.php" type="submit" class="btn btn-warning">Borrow Book</a>
<br><br>
</div>
</div>
</span>
<!– Tables –>
<br></br>
<br>
<div>
<table class="table table-bordered table-hover table-striped">
<tr align="center">
<td><b>TITLE</td>
<td><b>AUTHOR</td>
<td><b>ISBN</td>
<td><b>ACCESSION NUMBER</td>
<td><b>BOOKS AVAILABILITY</td>
</tr>
<?php while($row = mysqli_fetch_array($search_result)):?>
<td> <?php echo $row['title'];?> </td>
<td> <?php echo $row['author'];?> </td>
<td> <?php echo $row['ISBN'];?> </td>
<td> <?php echo $row['accession_number'];?> </td>
<td> <?php echo $row['books_availability'];?> </td>
</tr>
<?php endwhile;?>
</table>
</form>
</tr>
</body>
</html>
Thanks , This was exactly the tutorial I am looking for .
I have question : How can I search between 2 tables ? please help me
how can we create a link in the sesrch results?
best tutorial
its good but im use another but your code help me for more secure and i use your some code
this happend when i click submit btn ( ! ) Warning: mysqli_query() expects at least 2 parameters, 1 given in C:Documents and SettingsracunarDesktopwampwwwMoja stranicaindex.php on line 10
Call Stack
# Time Memory Function Location
1 0.0007 375984 {main}( ) ..index.php:0
2 0.0279 382160 mysqli_query ( ) ..index.php:10
HELP
looks complicated
What algorithm is used here(I mean like binary search, depth first search etc)? I want to know the algorithm. Thanks
Thank you sir
Thank you sir
Thank you so much!
Hey. When I load the page, it gives me this error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '%% OR last_name LIKE '%%'' at line 1
i mean 12:21
you put anme in minute 12:05
i want the source file please
+1 sub
Plz Send me the code of this toturial Plzzzz…….
hi sir.
you can sent for me this code source?
Creating a PHP Search & PHP paginations How do I get the codes? Could you send me the address?oktay52@gmail.comThank you…
How do you display multiple records with the same name ? I mean I've tried also your way but I still it doesn't display multiple results. Maybe because of some coding in java which is included in my code?
Do you have the files for mee please?