Normally, you displayed data results without order in php. If you want to display single data, then you can easily display it using ' <?php echo $name; ?> '. But if you have to display large amount of data from mysql table, then you should be display it properly. So only, you can understand the displayed results. So the best option for display data is table. You can display results orderly in table using php. The following mysql query is used to select the values from mysql table.
SELECT * FROM table_name
Now you'll get output like this:
Now you can get your results in table.
SELECT * FROM table_name
Display results in table using php and mysql:
You can retrieve data from mysql table using php. The php script for display data in table as follows as:
<html>
<body>
<style type="text/css">
th,td{
border-width:0px 1px 1px 0px;
}
</style>
<?php
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('new') or die(mysql_error());
$query=mysql_query("select * from table1 limit 0,10") or die(mysql_error());
echo'<table border="1" ><th >Reg.Id</th><th>Name</th><th>Category</th>';
while($res=mysql_fetch_array($query))
{
echo'<tr><td>'.$res['game_ID'].'</td><td>'.$res['game_Title'].'</td><td>'.$res['category_Name'].'</td></tr>';
}
echo'</table>';
?>
</body>
</html>
<body>
<style type="text/css">
th,td{
border-width:0px 1px 1px 0px;
}
</style>
<?php
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('new') or die(mysql_error());
$query=mysql_query("select * from table1 limit 0,10") or die(mysql_error());
echo'<table border="1" ><th >Reg.Id</th><th>Name</th><th>Category</th>';
while($res=mysql_fetch_array($query))
{
echo'<tr><td>'.$res['game_ID'].'</td><td>'.$res['game_Title'].'</td><td>'.$res['category_Name'].'</td></tr>';
}
echo'</table>';
?>
</body>
</html>
Now you'll get output like this:
Now you can get your results in table.
Good tuto...
ReplyDeleteoh wait!
My god IT'S A TRAP!
suppose we have a table with 20000 data, and we need to display with a NEXT and PREVIOUS buttons, how we can do that?
ReplyDeleteFor that you can use pagination concept in PHP.
DeleteVisit this post http://www.phponwebsites.com/2014/04/php-mysql-pagination.html
Awesome tut bro. Even on the pagination link. Thanks.
ReplyDeleteHow to get values from HTML table using PHP.
ReplyDelete