Tuesday, 1 December 2015

View registraion details in a table with alternate row color

Dear Friends,
You can display the details in the table with alternate row and text color using this code.

viewadmission.php


<html>
<head>
<title>
Registered Candidates
</title>
<body >
<!--
Coded by Prof. Sajeev Jaladharan
Date : 27.11.2015
email: sajeevjal@gmail.com
-->
<?php



$con = mysql_connect("localhost","root","");
if (!$con)
  {
      die('Could not connect: ' . mysql_error());
  }

mysql_select_db("snit",$con);
$result = mysql_query("SELECT * FROM student order by id");

?>
 <table width="81%" border="0"  align="center">
<tr>
      <td colspan="12" align="center" width='300'><img id=bg src="images/bgacademic.jpg"  /> </td>
     
     
    </tr>
<tr>
      <th>Id</th>
      <th>Name</th>
      <th>City</th>
      <th>State</th>     
      <th>Email</th>
      <th>LPhone</th>
      <th>Mobile</th>
      <th>Qualification</th>
      <th>Subject</th>
      <th>College</th>
     
    </tr>

<tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>

<?php
$i=-1;
while($row = mysql_fetch_array($result))
  {
    if($i==1)
    {
        $clr="#FFFFFF";       
        $tclr="#000000";
    }
    else
    {
        $clr="#666666";
        $tclr="#FFFFFF";
    }
    $i=$i * -1;

    echo "<tr>";
      echo "<td  bgcolor='$clr'><font color='$tclr'>".$row['id'] . "</font></td> ";
    echo "<td  bgcolor='$clr'><font color='$tclr'>".$row['Name'] . "</font></td> ";
    echo "<td  bgcolor='$clr'><font color='$tclr'>".$row['City'] . "</font></td> ";
      echo "<td bgcolor='$clr'><font color='$tclr'>".$row['State'] . "</font></td> ";
    echo "<td bgcolor='$clr'><font color='$tclr'>".$row['Email'] . "</font></td> ";
    echo "<td  bgcolor='$clr'><font color='$tclr'>".$row['Land'] . "</font></td> ";
      echo "<td bgcolor='$clr'><font color='$tclr'>".$row['Mobile1'] . "</font></td> ";
      echo "<td bgcolor='$clr'><font color='$tclr'>".$row['Qualification'] . "</font></td> ";
    echo "<td  bgcolor='$clr'><font color='$tclr'>".$row['Subject'] . "</font></td> ";
      echo "<td bgcolor='$clr'><font color='$tclr'>".$row['College'] . "</font></td> ";
   
    echo "</tr>";
  }

mysql_close($con);
?>


   
  
  </table>
  <div class="info" align="center">
    <h2>&nbsp;</h2>
</div>

<ul><p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

</body>
</html>



No comments:

Post a Comment