标签:好友 date color else rtm -- tap ppi json
1.当遍历是一条数据,取数据是个数据需要遍历,只需要取
$base[‘y_slide‘] = unserialize($base[‘y_slide‘]);
$num = count($base[‘y_slide‘]);
for($i = 0; $i < $num; $i++) {
$base[‘y_slide‘][$i]=$_W[‘attachurl‘].$base[‘y_slide‘][$i];
}
foreach ($item as &$values) {
$values[‘k_slide‘] = unserialize($values[‘k_slide‘]);
$num = count($values[‘k_slide‘]);
for ($i = 0; $i < $num ; $i++) {
$values[‘k_slide‘][$i]=$_W[‘attachurl‘].$values[‘k_slide‘][$i];
}
}
3.传数据给下一个页面传id
//专家检索
public function doPageYuZhuanjiajiansuo(){
global $_W,$_GPC;
$uniacid = $_W[‘uniacid‘];
$keshi = $_REQUEST[‘keshi‘];
$zhicheng = $_REQUEST[‘zhicheng‘];
$shanchang = $_REQUEST[‘shanchang‘];
$where = " where uniacid=:uniacid";
if (!empty($keshi)) {
$where.=" and keshi=:keshi";
$data[":keshi"] = $keshi;
}
if (!empty($zhicheng)) {
$where.=" and z_zhicheng=:zhicheng";
$data[":zhicheng"] = $zhicheng;
}
if (!empty($shanchang)) {
$where.=" and z_shanchang like ‘%$shanchang%‘"; //很多不止一个,
}
$data[‘:uniacid‘] = $uniacid;
$sql = "SELECT * FROM ".tablename("hyb_ylxc_zhuanjia").$where;
// $sql = "SELECT * FROM ".tablename("hyb_ylxc_zhuanjia")."where uniacid=:uniacid",array(":uniacid"=>$uniacid);
$list = pdo_fetchall($sql,$data);
if (!empty($list)) {
foreach ($list as &$value) {
$value[‘z_thumbs‘] = $_W[‘attachurl‘].$value[‘z_thumbs‘];
$base = pdo_fetch("SELECT * FROM ".tablename("hyb_ylxc_base")." where uniacid=:uniacid",array(":uniacid"=>$uniacid));
$value[‘yiyuan‘] = $base[‘y_title‘];
}
}
return $this->result(0,"success",$list);
}
9.用户授权
//获取用户信息
public function doPageTyMember() {
global $_GPC, $_W;
$uniacid = $_W[‘uniacid‘];
$openid = $_REQUEST[‘openid‘];
// $openid = "oiw7_0FlOxmb4SmYHwT7K0rBdCnY";
$item[‘u_name‘] = $_GPC[‘u_name‘];
$item[‘u_thumb‘] = $_GPC[‘u_thumb‘];
$item[‘uniacid‘] = $uniacid;
if ($openid) {
$res = pdo_update(‘hyb_ylxc_userinfo‘, $item, array(‘openid‘ => $openid));
}
if (!$res[‘u_id‘]) {
$res = pdo_fetch(‘SELECT `u_id` FROM ‘ . tablename(‘hyb_ylxc_userinfo‘) . " where `openid`=‘{$openid}‘");
}
$message = ‘success‘;
$errno = 0;
return $this->result($errno, $message, $item);
}
public function doPageGetUid() {
global $_GPC, $_W;
$uniacid = $_W[‘uniacid‘];
$result = pdo_fetch(‘SELECT * FROM ‘ . tablename(‘hyb_ylxc_key‘) . " where `uniacid`=‘{$uniacid}‘");
// $APPID = "wxbcf230862644aa93";
$APPID = $result[‘appid‘];
$SECRET = $result[‘appsecret‘];
// $SECRET = "1ad4414c9da569ca333d216cc6d0f643";
$openid = $_REQUEST[‘openid‘];
$openid = "oiw7_0FlOxmb4SmYHwT7K0rBdCnY";
$code = trim($_GPC[‘code‘]);
$url = "https://api.weixin.qq.com/sns/jscode2session?appid={$APPID}&secret={$SECRET}&js_code={$code}&grant_type=authorization_code";
$data[‘userinfo‘] = json_decode($this->httpGet($url));
$openid = $data[‘userinfo‘]->openid;
$item[‘openid‘] = $openid;
if ($openid) {
$res = pdo_fetch(‘SELECT `u_id` FROM ‘ . tablename(‘hyb_ylxc_userinfo‘) . " where `openid`=‘{$openid}‘");
if (!$res[‘u_id‘]) {
$res = pdo_insert(‘hyb_ylxc_userinfo‘, $item);
}
}
$data[‘openid‘] = $openid;
$message = ‘success‘;
$errno = 0;
return $this->result($errno, $message, $data);
}
private function httpGet($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
curl_close($curl);
return $res;
}
10 查询男女 数据库是1 0,页面显示男女
$sex = $data["h_sex"];
if($sex==1){
$data[‘h_sex‘] = "女";
}
else{
$data[‘h_sex‘] = "男";
}
11.
标签:好友 date color else rtm -- tap ppi json
原文地址:https://www.cnblogs.com/isuansuan/p/9861390.html