ym.php:
数据发布#box{width:900px;margin:20px auto 0px;padding-left:25px;
background:orange;border-radius: 10px;}
.text{width:870px;height:100px;margin-top: -20px;font:bold 25px/1em '黑体';resize: none;}
input{width:100px;height:30px;font:bold 20px/1em '黑体';}
ul{margin-top:3px;}
ul li{color:red;width:830px;border-bottom: 1px dashed blue;font:bold 18px/1.5em '黑体';}
a{width:60px;float:right;color:red;background:#ccc;
text-align:center;text-decoration:none;font:bold 20px/1em '黑体';}
a:hover{background:black;}
.a1{color:red;background:#ccc;float:right;margin-right:10px;}
header("Content-Type:text/html;charset=UTF-8");
include 'db.php';
$db = new DB();
if(isset($_POST['submit'])){
$a = $_POST['content'];
$date = date('Y-m-d H:i:s');
$sql = "insert into hh value(null,'$a','$date')";
$db->insert($sql);
// if(){
// //echo "";
// }
// if(empty($sql['content'])){
// echo "";
// }
}
?>
请输入发布数据内容
$sql = "select * from hh";
$res= $db->get($sql);
// $data=json_encode($res);
// echo $data;
for($i=1; $i <= count($res); $i++) {
$id = $res[$i-1][0];
$str = $res[$i-1][1];
echo "
发布数据$i: $str ";}
if (@$_GET['str']=='del') {
$id=$_GET['id'];
include_once('db.php');
$sql="delete from hh where id=$id";
$res=$db->delete($sql);
}
?>
ajax.html
查看数据内容#box{position:relative;width:700px;font:bold 20px/1.5em '黑体';margin:20px auto 0px;
background:orange;padding-left:30px;color:red;margin-top:-5px;border-radius: 10px;}
#div1{width:720px;height:50px;background:pink;margin:5px auto 0px;
text-align: center;font:bold 30px/1.5em '黑体';border-radius: 10px;}
#btn1{position:absolute;width:130px;height:50px;margin-left:180px;
margin-top: 140px;font:bold 20px/1.5em '黑体';}
$(function(){
$('#btn1').bind('click', function(){
$.ajax({
url:"data.php",
type:"get",
success:function(data){
$("#box").html(data);
}});
});
})