$host = 'localhost'; $user_name = 'root'; $password = 'admin'; $conn = mysql_connect($host,$user_name,$password); if(!$conn) { die('資料庫連接失敗:'.mysql_error()); } mysql_select_db('test'); $sql = 'select id,name,city,created_time from users'; $result = mysql_query($sql) or die("<br/>error: <b>".mysql_error()."</b><br/>產生問題的sql:".$sql); ?> <html> <head> <title>13-12.php</title> <script language="網頁特效"> </script> </head> <center> <body> <table width="75%" border="0" cellpadding="0" cellspacing="1" bgcolor="#7b7b84"> <tr bgcolor="#8bbcc7"> <td height="33"><div align="center"><strong>使用者id</strong></div></td> <td><div align="center"><strong>使用者名稱稱</strong></div></td> <td><div align="center"><strong>來自城市</strong></div></td> <td><div align="center"><strong>註冊時間</strong></div></td> <td><div align="center"><strong>操作</strong></div></td> </tr> <?php if($num = mysql_num_rows($result)) { while($row = mysql_fetch_array($result,mysql_assoc)) { ?> <tr bgcolor="#ffffff"> <td height="22" align="right"><?php echo $row['id']; ?> </td> <td height="22"> <?php echo $row['name']; ?> </td> <td height="22"> <?php echo $row['city']; ?> </td> <td height="22"> <?php echo $row['created_time']; ?> </td> <td height="22"> <a onclick="javascript:if(confirm('確定要刪除使用者資訊嗎?')) return true; else return false;" href="13-13.php?id=<?php echo $row['id']; ?>">刪除</a> </td> </tr> <?php } } mysql_close($conn); ?> </table> </body> </center> </html> |