PHP, MySQL, Drupal, .htaccess, Robots.txt, Phponwebsites

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.