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

";
		}
    mysqli_close($con);
    ?>

How to Display MySQL Table Data Tutorial

index.php



 
       
           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 ' 
                  '.$inputdata1name.' 
                  '.$inputdata2name.' 
                  '.$inputdata3name.' 
                  '.$inputdata4name.' 
                  '.$inputdata5name.' 
              ';
    }
    $result->free();
} 
?>


HTML code

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

insert.php

real_escape_string($_POST['productval1']);
$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}')";

$mysqli->query($query);
$mysqli->close();

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 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.

Leave a Comment