【发布时间】:2015-01-20 10:47:05
【问题描述】:
我定制了这个页面mysql.php,但目前它在浏览器上显示为空白。
<html>
<head>
<title> MySQL Test </title>
</head>
<body>
<?php
$username = "username";
$password = "pass";
$hostname = "localhost";
$dbname = "StudentLessons";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password, $dbname)
or die("Unable to connect to MySQL");
echo "Connected to MySQL <br>";
$query = "SELECT * FROM Teacher GROUP BY bathmida";
$result = mysql_query($query);
echo "<table>"; // start table in html
while($row = mysql_fetch_array($result)) { //loop through results
echo "<tr><td>" . row['onoma'] . "</td><td>" . row['epitheto'] "</td><td>" . row['bathmida'] "</td></tr>"; //$row['index'] is a filed name
}
echo "</table>"; //close table
mysql_close(); //close the db connection
?>
</body>
</html>
现在我知道了一个事实
- 连接是合法的。
- 查询正常,因为我对它们都进行了测试。
我还在 [so] 上建议了另一个 question,看来我错过了一些重要的东西。 HTML 中的<tr><td> 标签设置为应有的状态,那么可能是什么问题?
顺便说一句,有没有其他方法可以稍微自动化这个过程?即开发一种可以支持更多查询等的表单?
【问题讨论】: