Example #1
0
require dirname(__FILE__) . '/wp-load.php';
/*输出图片信息*/
$page = intval($_GET['page']);
//获取请求的页数
$id = intval($_GET['typ']);
$array = array();
/*
for($i = 0; $i< 15 ; $i++){
	 $arr[] = array( 
        'content'=>sprintf('conteent%d', $i), 
        'author'=>sprintf('author %d', $i), 
        'date'=>date('m-d H:i'), 
    ); 
}
*/
$arr = getTrendItemWithPage($id, $page);
$count = count($arr);
//为奇数,变为偶数,保证为2的整数倍
if ($count % 2 != 0) {
    $count--;
}
for ($i = 0; $i < $count; $i++) {
    $ret_arr[] = array('left' => array('pic' => $arr[$i]->pic, 'name' => $arr[$i]->name), 'right' => array('pic' => $arr[$i + 1]->pic, 'name' => $arr[$i + 1]->name));
    //array_push($ret_arr, array('left'=> array('pic'=>$arr[$i]->pic,'name'=>$arr[$i]->name), 'right' => array('pic'=>$arr[$i+1]->pic,'name'=>$arr[$i+1]->name)));
}
//var_dump($ret_arr);
//echo $_GET['callback']."(".$json_encode($ret_arr).")";
echo json_encode($ret_arr);
//转换为json数据输出
//echo 'test';
Example #2
0
   <table width="100%" border="0" cellpadding="0" cellspacing="0" id = "trendtable">
    <?php 
include "top_bar.php";
?>
    <tr>
     <td>
      <table>
       <?php 
include "top_link.php";
?>
       <?php 
include "top_nav.php";
?>
        <?php 
// 获取最开始的数据
$trendItems = getTrendItemWithPage(1, 0);
?>
       <?php 
$i = 1;
?>
       <tr>
        <td>
         <div><img src="images/trend/trend_style.gif" width="149" height="41" style="margin:50 0 0 10px;"></div>
		</td>
       </tr>
	   <?php 
for ($i = 0; $i < count($trendItems) - 1; $i++) {
    ?>
       <tr>
        <td>
		 <div class="trend_border1" >