How to fetch data from DB and fetch data in table form.


 create a html table in your web application where you want  to fetch data. and apply coding like below.

//                                        Code                                               //

<!DOCTYPE html>
<html>
<body>

<?php

include"config.php";
?>
<table width="50%" border="1">
<?php
 $sql = "select * from employer";
$row=mysql_query($sql);

?>
  <tr>
    <td>Id;</td>
    <td>Emp-Name;</td>
    <td>Emp- Address;</td>
    <td>Mobile Nomber;</td>
    <td>Salary;</td>
  </tr>

<?php  while($data=mysql_fetch_array($row)) { ?>
  <tr>
  <td><?php echo $data['id'];?></td>
    <td><?php echo $data['Emp-name'];?></td>
    <td><?php echo $data['Emp-address'];?></td>
    <td><?php echo $data['Mobile - Number'];?></td>
    <td><?php echo $data['Salary'];?></td>
    <td><?php ?></td>
  </tr>

  <?php } ?>
</table>
?>

</body>
</html>



How to provide edit option in your fetch data table in your admin panel.    

1 create a new page edit.php2 same as form like submit details3 in index file wherer table data show creata a new colom and insert botton edit.

//                        Code                                //
<td><form action="edit.php" method="post" name="edit1"><input name="Edit" type="submit" value="Edit"><input name="id" id="user-id" type="hidden" value="<?php echo $data['id'];?>"></form></td>

and redirect edit page to index page after click on submit botton like


<?php
include "config.php";
?>


<form action="index.php" method="post" name="submit room">

  


Comments

Popular posts from this blog

How to filter data from database according to client name & date wise in PHP

Captcha Code In PHP