infolink

Wednesday, 28 March 2012

Display Data in the Gridview from the Database in PHP

This new tutorial or post is about how the data show in the Gridview from database in PHP.
I am using the same database which i created in the previous post Or tutorial ((PHP Form Tutorial).
Database Name:  clientinformation
Table Name:    client_reg

Here is the PHP code for displaying the data in the gridview or table form:

<table width="100%" border="1">
        <tr> 
          <td><strong><font color="#000000">ID</font></strong></td>
          <td><strong><font color="#000000">Client Name</font></strong></td>
          <td><strong><font color="#000000">Address</font></strong></td>
          <td><strong><font color="#000000">CNIC</font></strong></td>
          <td><strong><font color="#000000">Mobile #</font></strong></td>
          <td><strong><font color="#000000">Telephone #</font></strong></td>
          <td><strong><font color="#000000">Company Name</font></strong></td>
          <td><strong><font color="#000000">Client Status</font></strong></td>
          <td><strong><font color="#000000">Register Date</font></strong></td>
 <td><strong><font color="#000000">Edit/Delete/Complaints</font></strong></td>
        </tr>
<?PHP
include("dbconnection.php");
$sql = "SELECT * FROM `client_reg` Order by Id DESC ";
//echo $sql;exit;
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
?>
        <tr> 
          <td><?php echo $row['Id']; ?></td>
          <td><?php echo $row['ClientName']; ?></td>
          <td><?php echo $row['Address']; ?></td>
          <td><?php echo $row['CNICNumber']; ?></td>
          <td><?php echo $row['MobileNumber']; ?></td>
          <td><?php echo $row['TelephoneNumber']; ?></td>
          <td><?php echo $row['CompanyName']; ?></td>
          <td><?php
  if($row['ClientStatus']==1)
{
echo "Active";
}
else
{
echo "Inactive";
?></td>
          <td><?php echo $row['RegisterDate']; ?></td>
         
  <td><a href="Clientedit.php?cid=<?php echo $row['Id']; ?>"><strong>Edit</strong></a> | <a href="Clientdel.php?action=delete&id=<?php echo $row['Id']; ?>"><strong>Delete</strong></a> | <a href="Clientcomplaintlist.php?cid=<?php echo $row['Id']; ?>"><strong>Complaints</strong></a></td>
        </tr>
<?php
}
?>

--------------------------------------------------------------

The Output of this PHP code is:

Data in GridView
Data in Grid View

12 comments:

  1. it's not working. display did't view

    ReplyDelete
  2. Hi, now i got the idea abt how to do that.

    Thank you.

    If possible can u send me any sample project file on rdandnayak@gmail.com if u have any.

    ReplyDelete
  3. can you show code of Clientedit.php and Clientdel.php...!
    I don't know do how to do that?

    ReplyDelete
  4. can u say if the grid is possible in jsp thanks in advance

    ReplyDelete
  5. Grid didn't show. wonder why..

    ReplyDelete
  6. Hello sir can you send sample project file to me yoemnga@gmail.com ?

    ReplyDelete
  7. please upload all files here...

    ReplyDelete
  8. How to display in grid view only number of tabls.in php

    Not auto genreted columns plizzz help me

    ReplyDelete
  9. here you display only table ... we need to display data in a gird view where 4 rows and 3 columns .. each th show single record ... explain this please

    ReplyDelete
  10. Delete, Edit and Complain file missing Please upload or send on my id pparesh13@gmail.com

    ReplyDelete