📜  在 php 代码示例中显示数据库表

📅  最后修改于: 2022-03-11 14:54:50.591000             🧑  作者: Mango

代码示例1
$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 ""; // start a table tag in the HTML

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

echo "
" . $row['name'] . "" . $row['age'] . "
"; //Close the table in HTML mysql_close(); //Make sure to close out the database connection