Search system using php and MySQL

Search system using php and MySQL

Now a days everyone is looking for quick response because they don’t want to waste their time and they simply search what they want using search feature in every website on the internet. Ever every online product have searching facility for easy use of user. So are you getting error/problem for creating search system in php ?  please follow the below steps to create search system in php.

How to create search system using php and MySQL ??
  1. Create new page called index.php to get search value using form.
  2. Create one database table to store data.
  3. Create another page search.php to retrieve data from database.

Now, let’s see code to develop search system.

1.    Create page index.php

First you need to create page and write a code for making form to get value of search by using html form. Follow the below code to create form using html. Make sure the method of form to be POST.

    <div class="container">
        <form method="POST" action="search.php" class="search-form">
            <div class="form-group">
                <input type="text" name="search" placeholder="What are you looking for?">
                <button type="submit" class="submit"><i class="icon-search"></i></button>
2.    Create one database table to store data
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
3.    Create another page called search.php to retrieve data of search value.

To get value of search write the below code at the top of page.

php $searchdata=$_POST['search'];

To retrieve data from data base write below code after above code

$query= "select * from MyGuests where firstname  like '%$searchdata%'";
$data = mysqli_query($conn, $query);
while($result= mysqli_fetch_assoc($data)) { ?>
    echo $result[‘firstname’];

That’s all this is how to develop simple search system using php and MySQL. I hope you like this article. Don’t forget to share with your friend to help them.

Also Read:

Whatsapp Update: Login Up to Four devices using one Number

Post Comments(0)

Leave a reply