database name :dbstud table name : tblstud fields rno tinyint autoincrement and primary key name varchar 20 gender enum "m","f" city varchar 20
<?php
$link=mysql_connect("localhost","root","");
$db=mysql_select_db("dbstud");
$res=mysql_query("select *from tblstud");
echo $res,"<BR>";
echo "<table border=1>";
while($row=mysql_fetch_array($res,MYSQL_NUM))
{
echo "<TR bgcolor='yellow'>";
foreach($row as $k=>$v)
{
if($k == 2)
{
if($v=="f")
{
echo "<td bgcolor='pink'>Female</td>";
}
else
{
echo "<td bgcolor='cyan'>Male</td>";
}
}
else
{
echo "<td>",$v,"</td>";
}
}
echo "</TR>";
}
echo "<table>";
?>
No comments:
Post a Comment