PDO<\/a> or MySQLi tutorial.This post will be delete or revised in the future.<\/p>\n<\/div>\nThis question has been asked several times lately and I wanted to clear this up. This is a very easy concept once you get it down. In order to display the results from a MySQL query into a table will will store the results in an array and then echo out each row in a while loop.<\/p>\n
First off. I am going to use a table that I created in the past tutorials on this site.<\/p>\n
The table contains the following fields:<\/p>\n
ID – auto generated integer \nFName – First Name, varchar \nLName – Last Name, varchar \nPHON – Phone number, varchar<\/p>\n
Create the table and populate some test data if you haven’t done so already. If you don’t know how to do this please visit some of our other MySQL tutorials.<\/p>\n
Create your database connection<\/p>\n
\r\n<?php\r\n\/\/create a database connection\r\nmysql_connect("localhost","your username","password") or die("Error: ".mysqlerror());\r\n\/\/select your database\r\nmysql_select_db("your db");\r\n?>\r\n<\/pre>\nNext we need to setup the table. We will add the column headings.<\/p>\n
\r\n<?php\r\n\/\/create a database connection\r\nmysql_connect("localhost","your username","password") or die("Error: ".mysqlerror());\r\n\/\/select your database\r\nmysql_select_db("your db");\r\n?>\r\n\r\n<html>\r\n<body>\r\n\r\n<table border=1>\r\n <tr>\r\n <th>ID<\/th>\r\n <th>First Name<\/th>\r\n <th>Last Name<\/th>\r\n <th>Phone Number<\/th>\r\n <\/tr>\r\n<\/pre>\nAs you can see above we ended our PHP code and create an HTML table. The TR tage is used to defined a table row and the TH tag is used for Table Headings.<\/p>\n
In php you can “break” out of code and execute HTML and then continue writing php code. Do do this you simply end your php code with then start a new <\/p>\n","protected":false},"excerpt":{"rendered":"
This question has been asked several times lately and I wanted to clear this up. This is a very easy concept once you get it down. In order to display the results from a MySQL query into a table will will store the results in an array and then echo out each row in a while loop.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[24,17],"tags":[49,52,47,70],"yoast_head":"\n
How to Return MySQL Results to a Table<\/title>\n \n \n \n \n\t \n\t \n\t \n