Sunday, February 5, 2017

ID Fields Listing in PHP and MySQL

I have encounter a problem regarding how to display a series of numbers in the number or id field in PHP and MySQL when we want to display a series of records in our field. Actually the solution is a very simple looping statement to increment in ascending order every time we at records in our tables here is the solution below. I hope you will find my work useful.  Thank you.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

<html>
<body>
<style type="text/css">
th,td{
border-width:0px 1px 1px 0px;
}
</style>
<?php
$counter=1;
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('profile')  or die(mysql_error());
$query=mysql_query("select * from user_table ")  or die(mysql_error());
echo'<table border="1" ><th >ID</th><th>Name</th><th>Work</th>';
while($res=mysql_fetch_array($query))
{
  echo'<tr><td>'.$counter.'</td><td>'.$res['name'].'</td><td>'.$res['work'].'</td></tr>';
  $counter++;
}
echo'</table>';
?>
</body>
</html>





No comments:

Post a Comment