日期:2014-05-17 浏览次数:20705 次
<?php
header("Content-Type:text/html;charset=utf-8");
mysql_connect('localhost','colg_demo','colg__');
mysql_select_db('colg_demo');
function getdata($sql)
{
$result=mysql_query($sql);
if($result)$count = mysql_num_rows($result);
for($i=0;$i<$count;$i++)
{
mysql_data_seek($result,$i);
$data[$i] = mysql_fetch_assoc($result);
}
return $data;
}
$data = getdata("select * from demo");
?>
<style type="text/css">
.left{float:left;width:100px;border:1px solid grey;height:300px;}
.right{float:left;width:800px;border:1px solid grey;height:300px;margin-left:15px;}
.left_button{margin:5px;border:1px solid #ccc;cursor:pointer;}
td{margin:1px;border:1px solid #ccc;}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".left_button").click(function(){
$(this).css("background","#EEE");
$(this).siblings().css("background","white");
var n = $(this).text();
$.ajax({
type:"get",
url:"ajax.php",
data:{
n:n
},
success:function(msg){
msg = eval("("+msg+")")
$(".show_tr").html(msg);
}
});
});
});
</script>
<div class="left">
<?php foreach($data as $each){?>
<div class="left_button"><?php echo $each['col3'];?></div>
<?php } ?>
</div>
<div class="right">
<table>
<tr>
<td>id</td>