index.php页面:
<?php header("Content-type: text/html; charset=gb2312");?>
<style>
*{font-size:12px;padding:0;margin:0;}
ul,li{list-style:none}
div{width:30%;float:left;margin-right:3.333%}
</style>
<script src="jquery-1.9.1.min.js"></script>
<script>
$.ajax({
type:"GET",
url:"view.php",
data:{typeid:3},
beforeSend: function(){$("#con1").html("正在加载中......")},
success:function(data){
$("#con1").html(data);
}
})
$.ajax({
type:"GET",
url:"view.php",
data:{typeid:7},
beforeSend: function(){$("#con1").html("正在加载中......")},
success:function(data){
$("#con2").html(data);
}
})
$.ajax({
type:"GET",
url:"view.php",
data:{typeid:5},
beforeSend: function(){$("#con1").html("正在加载中......")},
success:function(data){
$("#con3").html(data);
}
})
</script>
<div>
<ul id="con1"></ul>
</div>
<div>
<ul id="con2"></ul>
</div>
<div>
<ul id="con3"></ul>
</div>
view.php页面:
<?php
header("Content-type: text/html; charset=gb2312");
$mypdo=new pdo("mysql:host=localhost;dbname=news","root","");
$typeid=$_GET["typeid"];
$sql="selects * from news where typeid=$typeid limit 0,10";
$mypdo->query("set names gb2312");
$stmt=$mypdo->query($sql);
$rows=$stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $rs){
echo "<li>".$rs['title'].$rs['fdate']."</li>";
}
?>