左边导航右边内容切换 php,jquery ajax实现点击左侧菜单栏,右侧对应div处加载相关页面并显示...
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{w
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);
}});
});
})
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)