how to search and display data from database in php?

Today, We want to share with you how to search and display data from database in php.In this post we will show you how to fetch data from database in php and display in html table, hear for how to search and filter data in html table using php and mysql database [ with source code ] we will give you demo and example for implement.In this post, we will learn about Bootstrap Autocomplete Search Box / textbox in PHP MySQL with an example.

php mysql search database and display results

Example 1: php mysql search database and display results

<?php
    $link= new mysqli("localhost","root","","members_list");
    $name = $_post['search'];
    //$query = "SELECT * FROM members
   // WHERE start_name LIKE '%{$name}%' OR last_name LIKE '%{$name}%'";

    // Check database connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }

$result = mysqli_query($link, "SELECT * FROM members
    WHERE start_name LIKE '%{$name}%' OR last_name LIKE '%{$name}%'");

while ($row = mysqli_fetch_array($result))
{
        echo $row['start_name'] . " " . $row['last_name'];
        echo "<br>";
}
    mysqli_close($link);
    ?>

I hope you get an idea about how to fetch data from database in php using search button.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Also Read This 👉   check Element Hidden in jQuery