我是否必须通过phpmyadmin创建mysql表,以便php可以访问它? 我也使用MAMP来运行apache web服务器和mySql服务器。
<!DOCTYPE HTML>
<?php
//make connection
mysql_connect('localhost', 'root', '');
//select database
mysql_select_db('locker');
$sql= "SELECT * FROM locker";
$records=mysql_query($sql);
echo #records;
?>
<HTML>
<body>
<table width="600" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>username</th>
<th>UID</th>
<th>NoLoker</th>
</tr>
<?php
while ($locker=mysql_fetch_assoc($records))
{
echo "<tr>";
echo "<td>".$locker['username']."</td>";
echo "<td>".$locker['UID']."</td>";
echo "<td>".$locker['NoLoker']."</td>";;
echo "</tr>";
}//end while
?>
</table>
</body>