dede小程序数据调用

微信

17-3-13 8:54:07

require_once(dirname(__FILE__)."/include/common.inc.php");
header('Content-type:text/json');     //这句是重点,它告诉接收数据的对象此页面输出的是json数据;
//$json='{"name":"yovae","password":"12345"}';    //虽然这行数据形式上是json格式,如果没有上面那句的话,它是不会被当做json格式的数据被处理的;
//echo $json;

//获取品牌
$dsql="SELECT id,typename FROM  `dede_arctype` WHERE  `reid` =4 LIMIT 0 , 30";
$db->Execute('me',$dsql);
$pp=array();
while($arr = $db->GetArray())
{
$pp[]=$arr;
}


//获取数据
$dsql="SELECT id,title,litpic FROM  `dede_archives` where typeid in (SELECT id FROM  `dede_arctype` WHERE  `reid` =4) and litpic <>'' and id>20 ORDER BY  `id` desc LIMIT 0 , 5 ";
$db->Execute('me',$dsql);
$list=array();
while($arr = $db->GetArray())
{
$list[]= $arr;
}

$ad=array();
$ad[]=array("pic"=>"http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg","id"=>1);
$ad[]=array("pic"=>"http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg","id"=>2);
$ad[]=array("pic"=>"http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg","id"=>3);


$data['pp']=$pp;
$data['list']=$list;
$data['ad']=$ad;
echo json_encode($data);
//print_r($data);