showing database table in php

$connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
mysql_select_db('hrmwaitrose');

$query = "SELECT * FROM employee"; //You don't need a ; like you do in SQL
$result = mysql_query($query);

echo "<table>"; // start a table tag in the HTML

while($row = mysql_fetch_array($result)){   //Creates a loop to loop through results
echo "<tr><td>" . $row['name'] . "</td><td>" . $row['age'] . "</td></tr>";  //$row['index'] the index here is a field name
}

echo "</table>"; //Close the table in HTML

mysql_close(); //Make sure to close out the database connection

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
display database info as a table in php how to display database tables in php as a proper table display database table in php displaying database table in php display table from database in php show database and table in php show table from db using php code how to display database table in php php echo dynamic tables how to show database table using php how to display a database table in php show table sql php how to display mysql database on web page php sql view table show sql to php table print table from database php php echo data from database diplay data stored mysql in php display sql on html how to display sql table with php show sql result in html table sql echo tables html show sql data how to show sql table in html display sql table html how to display database tables in php how to show sql table row in php info from sql in table html displaying mysql data in html table php display sql table php show sql tabel php print from database echo database table php how to output sql into table in php html table sql php sql data show in html table php sql data show in tabe html php php table show in html sql data php print data from database how to print database table in php how to print database php displaying sql table in php php display data from database in table display sql data in html table php sql file display table print data from sql with php how to display mysql data in html table Showing table form mysql on website how to print a table in php from database how to show table from database in php user html to display data from mysql php sql output table
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source