php增删改查,自己写的demo
1.链接数据库通用方法:conn.php
<a href="add.php">添加内容</a><hr><hr><form> <input type="text" name="keys" /> <input type="submit" name="subs" value="搜索"/></form><?php include("conn.php");//引入链接数据库 if(!empty($_GET['keys'])){ $w=" title like '%".$_GET['keys']."%'"; }else{ $w=1; } $sql="select * from news where $w order by id desc"; $query=mysql_query($sql); while($rs=mysql_fetch_array($query)){ ?><h2>标题:<a href="view.php?id=<?php echo $rs['id'] ?>"><?php echo $rs['title'] ?></a> <a href="edit.php?id=<?php echo $rs['id'] ?>">编辑</a>||<a href="del.php?del=<?php echo $rs['id'] ?>">删除</a></h2><li><?php echo $rs['dates'] ?></li><p><?php echo $rs['contents'] ?></p><hr><?php}?>