PHP显示MYSQL数据库实例代码如下:
- <?php
-
-
-
-
-
-
- $conn=mysql_connect('localhost','root','');
- mysql_select_db('member',$conn);
-
-
- $sql="select * from user_list";
- $query=mysql_query($sql);
- while($row=mysql_fetch_array($query))
- {
- ?>
- <table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
- <tr bgcolor="#eff3ff">
- <td>id:<?=$row[uid]?> 用户:<?=$row[username] ?></td>
- </tr>
- <tr bgColor="#ffffff">
- <td>密码:<?=$row[password]?></td>
- </tr>
- <a href="del.php?id=<?=$row[uid]?>">删除</a>
- <? }?>
- </table>
数据库结构,把此代码复制到phpmyadmin运行,代码如下:
- SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-
-
-
-
-
-
-
-
-
-
-
- CREATE TABLE `user_list` (
- `uid` int(11) NOT NULL auto_increment,
- `m_id` varchar(5) NOT NULL,
- `username` varchar(25) NOT NULL,
- `password` varchar(64) NOT NULL,
- PRIMARY KEY (`uid`)
- ) ENGINE=MyISAM DEFAULT CHARSET=gb2312 AUTO_INCREMENT=11 ;
-
-
-
-
-
- INSERT INTO `user_list` (`uid`, `m_id`, `username`, `password`) VALUES
- (9, '1', 'admin', '75cf565ad38d0f837c43363e402b1a00'),
- (10, '2', 'admin2', '75cf565ad38d0f837c43363e402b1a00');
|