Wednesday, July 4, 2018

View Customers


Customers list is categorized according to the status of the customer as;

Here is the link to download the complete project folder.

Click to Download Project
  1. All Customers - shows all customers
  2. Suspended customers - shows only customer "status = S" is suspended
  3. Black Listed customer - shows only customer "status = B"
  4. Active Customers - shows customers with status = A
This is determined from the customers table status column. Color code is used to show different status in the table.

Source code of view_customers.php page


<?php include("header.php"); ?>
<h3>Customers</h3>
<p><strong>Filter:</strong> <a href="view_customers.php?t=A">Active</a> | <a href="view_customers.php?t=S">Suspended</a> | <a href="view_customers.php?t=B">Black Listed</a> | <a href="view_customers.php?t=all">All</a></p>
<table width="100%" style="background-color:#CC0000;" cellpadding="3px" cellspacing="1px">
<tr class="header">
<td>Date</td>
<td>Name</td>
<td>N.I.C.</td>
<td>Telephone</td>
<td>Address</td>
<td>Sex</td>
<td>Email</td>
<td>Stat.</td>
<td>&nbsp;</td>
</tr>
<?php
$status = $_GET['t'];
if($status != "all"){
$q = mysql_query("SELECT * FROM customers WHERE Cus_Status = '$status' ORDER BY Cus_Name");
}else{
$q = mysql_query("SELECT * FROM customers ORDER BY Cus_Name");
}
while($r = mysql_fetch_assoc($q)){
$cus_id = $r['Cus_ID'];
$cus_date = $r['Cus_Date'];
$cus_name = $r['Cus_Name'];
$cus_nic = $r['Cus_NIC'];
$cus_tel = $r['Cus_Tel'];
$cus_email = $r['Cus_Email'];
$sex = $r['Cus_Sex'];
$address = $r['Cus_Add'];
$c_status = $r['Cus_Status'];
echo "<tr class='";
if($c_status == "B"){
echo "lred";
}else if($c_status == "S"){
echo "lblack";
}else{
echo "wht";
}
echo "'>
<td>{$cus_date}</td>
<td>{$cus_name}</td>
<td>{$cus_nic}</td>
<td>{$cus_tel}</td>
<td>{$address}</td>
<td>{$sex}</td>
<td>{$cus_email}</td>
<td>{$c_status}</td>
<td><a href='edit_customer.php?id={$cus_id}'>Edit</a></td>
</tr> \n";
}
?>
</table>

<?php include("footer.php"); ?>
Share:

0 comments:

Post a Comment