Friday, 4 September 2015

Display the record of the emp in table format

To display the record in the table format, we will need to write the following code:
dispemp.php

<?php
    $cn=mysql_connect("localhost","root") or die(mysql_error());
    $db=mysql_select_db("student",$cn) or die(mysql_error());
    $row=mysql_query("select * from emp",$cn) or die(mysql_error());
    $no=mysql_num_rows($row);
    echo "<h2> Emp Details </h2>";
    echo "<table border=3>";
    echo "<tr><th>No<th>Name<th>Dept<th>Salary<th>TA<th>DA<Th>HRA<th>PF<th>NET";
    for($i=1;$i<=$no;$i++)
    {
        $data=mysql_fetch_row($row);
        echo "<tr>";
        echo "<td>".$data[0];
        echo "<td>".$data[1];
        echo "<td>".$data[2];
        echo "<td>".$data[3];
        echo "<td>".$data[4];
        echo "<td>".$data[5];
        echo "<td>".$data[6];
        echo "<td>".$data[7];
        echo "<td>".$data[8];
    }
    echo "</table>";
?>

No comments:

Post a Comment