Friday, 3 April 2020

Simple View in PHP

Hi All,
See the code.... ...

<?php


//include('connect.php');
//Db connection code here


$query = 'select * from student';
$result = mysql_query($query);
if (!$result)
{
$message = 'ERROR:' . mysql_error();
return $message;
}
else
{
$i = 0;
echo '<html><body><table border=1 align=center><tr>';
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result, $i);
echo '<th>' . ucfirst($meta->name) . '</th>';
$i = $i + 1;
}
echo '<th>Delete</th>';
  
$i = 0;
while ($row = mysql_fetch_row($result))
{
echo '<tr>';
$count = count($row);
$y = 0;
$idval='1';
while ($y < $count)
{
$c_row = current($row);
if($y==0)
$idval=$c_row;
echo '<td>' . $c_row . '</td>';
next($row);
$y = $y + 1;
}
echo '<td><a href=delstudent.php?id=$idval>Delete</a></td>';
    
echo '</tr>';
$i = $i + 1;
}
echo '</table></body></html>';
mysql_free_result($result);
}
mysql_close ($con);

?>

3 comments:

  1. It is nice post and I found some interesting information on this blog, keep it up. Thanks for sharing. . .
    PHP Database Development

    ReplyDelete
  2. Very good & informative content on topic
    Thanks for sharing such a useful tips.

    Visit our website for Custom software development company Vadodara

    ReplyDelete