In this article, how to filter table in active status in PHP and its very simple to fetch the data from the databases using PHP and display in HTML format. 

 

filter table in active status in PHP

 

In this method, we are already creating a database and table and table named as a student. 

Table of Contents:

1.Filter Table in Active Status in Php

2. Filter Table INActive Status in php

Methods: 

1. Connection with Database 

2. Fetch Data from the Database 

Here we are created to empty files : 

1.index.php 

2.dbconfig.php 

In this method, we are going to fetch the record using of select query from the database. Database:

filter table in active status in PHP



Filter Table in Active Status in PHP 


1. connection with database:

 In the empty file, dbconfig.php is used to make a connection with the database. it's a common file for all the PHP files to want to perform to fetch the records. Here, the code below:


<?php
$link='localhost';
$username='root';
$password='';
$con=mysqli_connect($link,$username,$password,"phptutorial");
if(!$con){
 die('Could not Connect MySqli:' .mysqli_error());
}
?>   




2. Fetch Data from the Database 

 In the file, index.php is used to visualize the table using HTML with using dbconfig.php for connecting the database Here the code below

   
<html>
<head>
<title>Dailyaspirants.com</title>
</head>
<body>

<h2>Filter Table in Active Status in PHP - Dailyaspirants</h2>

<table border="2">
<tr>
	   <th>Student_Id</th>
	   <th>Student Name</th>
	   <th>Dept Name</th>
	   <th>Status</th>
	   </tr>

<?php

include 'dbconfig.php';

$records = mysqli_query($con,"select * from student where status ='1'"); // fetch data from database

while($row = mysqli_fetch_array($records))
{
?>
  <tr>
    <td><?php echo $row['id']; ?></td>
    <td><?php echo $row['student_name']; ?></td>
    <td><?php echo $row['dept_name'] ;?></td>
    <td><?php echo $row['status'] ;?></td>
  </tr>	
<?php
}
?>
</table>

</body>
</html>
   
  

filter table in active status in PHP



Filter Table Inactive status in PHP 

Here the code Below:

  
  <html>
<head>
  <title>Dailyaspirants.com</title>
</head>
<body>

<h2>Filter Table  Inactive Status in PHP - Dailyaspirants</h2>
<table border="2">
<tr>
	   <th>Student_Id</th>
	   <th>Student Name</th>
	   <th>Dept Name</th>
	   <th>Status</th>
	   </tr>

<?php
include 'dbconfig.php';
$records = mysqli_query($con,"select * from student where status ='0'"); // fetch data from database
while($row = mysqli_fetch_array($records))
{
?>
  <tr>
    <td><?php echo $row['id']; ?></td>
    <td><?php echo $row['student_name']; ?></td>
	<td><?php echo $row['dept_name'] ;?></td>
    <td><?php echo $row['status'] ;?></td>
  </tr>	
<?php
}
?>
</table>
</body>
</html>
  
  



filter table inactive status in PHP

Post a Comment

Previous Post Next Post