PHP, MySQL, Drupal, .htaccess, Robots.txt, Phponwebsites: Display results in html table using php and mysql

13 Apr 2014

Display results in html table using php and mysql

                       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

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:

<style type="text/css">
border-width:0px 1px 1px 0px;
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>';

Now you'll get output like this:

Display data in table using php

                         Now you can get your results in table.


  1. Good tuto...
    oh wait!
    My god IT'S A TRAP!

  2. suppose we have a table with 20000 data, and we need to display with a NEXT and PREVIOUS buttons, how we can do that?

    1. For that you can use pagination concept in PHP.
      Visit this post

  3. Awesome tut bro. Even on the pagination link. Thanks.

  4. How to get values from HTML table using PHP.