how to fetch data from database in php using search button?

Today, We want to share with you php code search database and display results in table.In this post we will show you How To Find Data In MySQL Database Table By Id And Show The Results In Form Inputs In Php using MySQLI, hear for Php Code To Search Data In Mysql Database Table And Dispaly Results In Inputs Using MySQLI. we will give you demo and example for implement.In this post, we will learn about How To Search And Display Data From Database In Php with an example.

php mysql search database and display results


How to Display MySQL Table Data Tutorial


           Product Value1  
           Product Value2  
           Product Value3  
           Product Value4  
           Product Value5  

if ($result = $mysqli->query($query)) {
    while ($row = $result->fetch_assoc()) {
        $inputdata1name = $row["col1"];
        $inputdata2name = $row["col2"];
        $inputdata3name = $row["col3"];
        $inputdata4name = $row["col4"];
        $inputdata5name = $row["col5"]; 

        echo ' 

HTML code

Product Value1:
Product Value2:
Product Value3:
Product Value4:
Product Value5:


$inputdata2 = $mysqli->real_escape_string($_POST['productval2']);
$inputdata3 = $mysqli->real_escape_string($_POST['productval3']);
$inputdata4 = $mysqli->real_escape_string($_POST['productval4']);
$inputdata5 = $mysqli->real_escape_string($_POST['productval5']);

$query = "INSERT INTO products (col1, col2, col3, col4, col5)
            VALUES ('{$inputdata1}','{$inputdata2}','{$inputdata3}','{$inputdata4}','{$inputdata5}')";


I hope you get an idea about how to search and filter data in html table using php and mysql database [ with source code ].
I would like to have feedback on my 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.

Leave a Comment