数据库操作

来源:互联网 发布:英语在线发音软件 编辑:程序博客网 时间:2024/05/21 10:12

又在苦逼的写作业 !!!加油!!!!

1.已有数据库新加一个列

alter table tablename add colunmname int(type) not null;

2.加入数据

mysql> INSERT INTO `user` (`name`, `password`, `times`) VALUES
    -> ('linwang1', '90b282744ad3b8fca323237b2dc3bd62a35ac52a', '1350619409200'),
    -> ('linwang', '9fdfd2d9e1914589433a5fae4b4ba3c0a76d64b9', '1350622697905'); 
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from user;
+----------+------------------------------------------+---------------+
| name     | password                                 | times         |
+----------+------------------------------------------+---------------+
| linwang  | 9fdfd2d9e1914589433a5fae4b4ba3c0a76d64b9 | 1350622697905 |
| linwang1 | 90b282744ad3b8fca323237b2dc3bd62a35ac52a | 1350619409200 |
| admin    | d033e22ae348aeb5660fc2140aec35850c4da997 | 1350619409200 |
+----------+------------------------------------------+---------------+

3.修改数据

update user(table name) set privilege=1(column=value) where name='linwang1';

4.PHP 把数据库的信息打印到屏幕上

$finduser = $_POST['username'];

$p = mysql_query("SELECT * from user where name='$finduser';");
if($p){
echo "<table border=1><tr><th>username<th>password";
while ($row=mysql_fetch_array($p))
echo "<tr><td>$row[name]<td>$row[password]";
echo '</table>';
}else echo "ERROR_DATABASE";


原创粉丝点击