ecshop中 php json问题
我用的Ecshop程序做的商城,现要用到json,在网上找的一些代码:elseif($action=='collection_list1'){include_once(R...
我用的Ecshop程序做的商城,现要用到json,在网上找的一些代码:
elseif ($action == 'collection_list1')
{
include_once(ROOT_PATH . 'includes/lib_clips.php');
$page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
$record_count = $db->getOne("SELECT COUNT(*) FROM " .$ecs->table('collect_goods').
"WHERE user_id='$user_id' ORDER BY add_time DESC");
$pager = get_pager('user.php', array('act' => $action), $record_count, $page);
$smarty->assign('pager', $pager);
$smarty->assign('goods_list', get_collection_goods($user_id, $pager['size'], $pager['start']));
$smarty->assign('url', $ecs->url());
$lang_list = array(
'UTF8' => $_LANG['charset']['utf8'],
'GB2312' => $_LANG['charset']['zh_cn'],
'BIG5' => $_LANG['charset']['zh_tw'],
);
$smarty->assign('lang_list', $lang_list);
$smarty->assign('user_id', $user_id);
$goods_id = empty($_GET['goods_id']);
$arr_a = array(
"returncategory" =>$user_id,
"data" => array(
"newslist" => array(
array(
"title" => urlencode("$goods_name"),
"image" => "$goods_img",
"source" => urlencode("$goods_id"),
"commentcount" => $goods_cat,
"newsid" => 10
),
),
"totalnum" => 10
),
);
echo urldecode(json_encode($arr_a));
},运行user.php?act=collection_list1 得到:{"returncategory":"66","data":{"newslist":[{"title":"(1)","image":"(2)","source":"","(3)":120,"newsid":10}],"totalnum":10}},括号内没有值,比如:(2)应该是$goods_img的值,如能解决本人以50人民币以示感谢!!本人财富值不够了 展开
elseif ($action == 'collection_list1')
{
include_once(ROOT_PATH . 'includes/lib_clips.php');
$page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
$record_count = $db->getOne("SELECT COUNT(*) FROM " .$ecs->table('collect_goods').
"WHERE user_id='$user_id' ORDER BY add_time DESC");
$pager = get_pager('user.php', array('act' => $action), $record_count, $page);
$smarty->assign('pager', $pager);
$smarty->assign('goods_list', get_collection_goods($user_id, $pager['size'], $pager['start']));
$smarty->assign('url', $ecs->url());
$lang_list = array(
'UTF8' => $_LANG['charset']['utf8'],
'GB2312' => $_LANG['charset']['zh_cn'],
'BIG5' => $_LANG['charset']['zh_tw'],
);
$smarty->assign('lang_list', $lang_list);
$smarty->assign('user_id', $user_id);
$goods_id = empty($_GET['goods_id']);
$arr_a = array(
"returncategory" =>$user_id,
"data" => array(
"newslist" => array(
array(
"title" => urlencode("$goods_name"),
"image" => "$goods_img",
"source" => urlencode("$goods_id"),
"commentcount" => $goods_cat,
"newsid" => 10
),
),
"totalnum" => 10
),
);
echo urldecode(json_encode($arr_a));
},运行user.php?act=collection_list1 得到:{"returncategory":"66","data":{"newslist":[{"title":"(1)","image":"(2)","source":"","(3)":120,"newsid":10}],"totalnum":10}},括号内没有值,比如:(2)应该是$goods_img的值,如能解决本人以50人民币以示感谢!!本人财富值不够了 展开
2个回答
展开全部
"title" => urlencode("$goods_name"),
"image" => "$goods_img",
"source" => urlencode("$goods_id"),
你能不能把那个双引号取消先
"title" => urlencode($goods_name),
"image" => $goods_img,
"source" => urlencode($goods_id),
"image" => "$goods_img",
"source" => urlencode("$goods_id"),
你能不能把那个双引号取消先
"title" => urlencode($goods_name),
"image" => $goods_img,
"source" => urlencode($goods_id),
更多追问追答
追问
这个取消后会得到一个true,主要是提取不到$goods_id值,这代码应该怎么写,$goods_id是数据库的表字段的数据ID
追答
$goods_id = empty($_GET['goods_id']);
你这个不就是验证 $_GET['goods_id'] 这个是否为空值嘛
返回 true 就是对了呀
要不你改成
if(empty($_GET['goods_id'])){
$goods_id => $_GET['goods_id'];
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询