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.

Read Also:  Add Remove multiple Input Fields Dynamically in jQuery

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.

Read Also:  vuejs Smooth Scroll to Top

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  how to retrieve data from database in html form using PHP
  2. Read Also:  how to retrieve data from database and display it in textboxes using javascript?
  3. Read Also:  Simple Vue 2.0 Hello World Example
  4. Read Also:  PHP MySQL: Querying fetch Data from Database
  5. Read Also:  how to fetch data from database in php using search button?
  6. Read Also:  How to remove undefined value from Laravel PHP array?
  7. Read Also:  Retrieve Data From MySQL Using PHP
  8. Read Also:  like in sql
  9. Read Also:  Laravel Add active class to Nav Menu System
  10. Read Also:  how to fetch data from database in php mysql using search button?
CLOSEX