您说您在PhpMyAdmin上有一个数据库,因此您正在使用MySQL。PHP提供了用于连接到MySQL数据库的功能。
$connection = mysql_connect('localhost', 'root', ''); //The Blank string is the passwordmysql_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 HTMLwhile($row = mysql_fetch_array($result)){ //Creates a loop to loop through resultsecho "<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 HTMLmysql_close(); //Make sure to close out the database connection在while循环中(每次遇到结果行时都会运行),我们进行回显,以创建新的表行。我还添加了一个以包含字段。
这是一个非常基本的模板。您将使用mysqli_connect而不是mysql_connect看到其他答案。mysqli代表mysql改良。它提供了更好的功能范围。您会注意到它也有些复杂。这取决于您的需求。



