wap版 评论只有首页正常 后页全部显示Undefined variable: comment_data
2016-07-07 15:11 来源:www.chinab4c.com 作者:ecshop专家
Undefined variable: comment_data in D:\web\eachfa.com\mobile\comment.php on line 68
http://www.pctowap.com/air/eachf ... ?g_id=75&page=1 |
回答:
貌似只能查代码了,模板跳转看上去正常...
lilong1980 发表于 2012-11-17 23:02
冰天雪地求高手百忙之中 帮忙看一下:
-
- <?php
- /**
- * ECSHOP WAP评论页
- * ============================================================================
- * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
- * 网站地址: http://www.ecshop.com;
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * $Author: testyang $
- * $Id: comment.php 15013 2008-10-23 09:31:42Z testyang $
- */
- define('IN_ECS', true);
- require(dirname(__FILE__) . '/includes/init.php');
- $goods_id = !empty($_GET['g_id']) ? intval($_GET['g_id']) : exit();
- if ($goods_id <= 0)
- {
- exit();
- }
- /* 读取商品信息 */
- $_LANG['kilogram'] = '千克';
- $_LANG['gram'] = '克';
- $_LANG['home'] = '首页';
- $smarty->assign('goods_id', $goods_id);
- $goods_info = get_goods_info($goods_id);
- $goods_info['goods_name'] = encode_output($goods_info['goods_name']);
- $goods_info['goods_brief'] = encode_output($goods_info['goods_brief']);
- $smarty->assign('goods_info', $goods_info);
- /* 读评论信息 */
- $comment = assign_comment($goods_id, 'comments');
- $num = $comment['pager']['record_count'];
- if ($num > 0)
- {
- $page_num = '10';
- $page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
- $pages = ceil($num / $page_num);
- if ($page <= 0)
- {
- $page = 1;
- }
- if ($pages == 0)
- {
- $pages = 1;
- }
- if ($page > $pages)
- {
- $page = $pages;
- }
- $i = 1;
- foreach ($comment['comments'] as $key => $data)
- {
- if (($i > ($page_num * ($page - 1 ))) && ($i <= ($page_num * $page)))
- {
- $re_content = !empty($data['re_content']) ? encode_output($data['re_content']) : '';
- $re_username = !empty($data['re_username']) ? encode_output($data['re_username']) : '';
- $re_add_time = !empty($data['re_add_time']) ? substr($data['re_add_time'], 5, 14) : '';
- $comment_data[] = array('i' => $i , 'content' => encode_output($data['content']) , 'username' => encode_output($data['username']) , 'add_time' => substr($data['add_time'], 5, 14) , 're_content' => $re_content , 're_username' => $re_username , 're_add_time' => $re_add_time);
- }
- $i++;
- }
- $smarty->assign('comment_data', $comment_data);
- $pagebar = get_wap_pager($num, $page_num, $page, 'comment.php?g_id='.$goods_id, 'page');
- $smarty->assign('pagebar' , $pagebar);
- }
- $smarty->assign('footer', get_footer());
- $smarty->display('comment.html');
- ?>
复制代码 |
在循环前面声明一个 $comment_data = array() |
谢谢大神!加了后第二页仍然不显示评论
。- <?php
- /**
- * ECSHOP WAP评论页
- * ============================================================================
- * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
- * 网站地址: http://www.ecshop.com;
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * $Author: testyang $
- * $Id: comment.php 15013 2008-10-23 09:31:42Z testyang $
- */
- define('IN_ECS', true);
- require(dirname(__FILE__) . '/includes/init.php');
- $goods_id = !empty($_GET['g_id']) ? intval($_GET['g_id']) : exit();
- if ($goods_id <= 0)
- {
- exit();
- }
- /* 读取商品信息 */
- $_LANG['kilogram'] = '千克';
- $_LANG['gram'] = '克';
- $_LANG['home'] = '首页';
- $smarty->assign('goods_id', $goods_id);
- $goods_info = get_goods_info($goods_id);
- $goods_info['goods_name'] = encode_output($goods_info['goods_name']);
- $goods_info['goods_brief'] = encode_output($goods_info['goods_brief']);
- $smarty->assign('goods_info', $goods_info);
- /* 读评论信息 */
- $comment = assign_comment($goods_id, 'comments');
- $num = $comment['pager']['record_count'];
- if ($num > 0)
- {
- $page_num = '10';
- $page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
- $pages = ceil($num / $page_num);
- if ($page <= 0)
- {
- $page = 1;
- }
- if ($pages == 0)
- {
- $pages = 1;
- }
- if ($page > $pages)
- {
- $page = $pages;
- }
- $i = 1;
- $comment_data = array();
- foreach ($comment['comments'] as $key => $data)
- {
- if (($i > ($page_num * ($page - 1 ))) && ($i <= ($page_num * $page)))
- {
- $re_content = !empty($data['re_content']) ? encode_output($data['re_content']) : '';
- $re_username = !empty($data['re_username']) ? encode_output($data['re_username']) : '';
- $re_add_time = !empty($data['re_add_time']) ? substr($data['re_add_time'], 5, 14) : '';
- $comment_data[] = array('i' => $i , 'content' => encode_output($data['content']) , 'username' => encode_output($data['username']) , 'add_time' => substr($data['add_time'], 5, 14) , 're_content' => $re_content , 're_username' => $re_username , 're_add_time' => $re_add_time);
- }
- $i++;
- }
- $smarty->assign('comment_data', $comment_data);
- $pagebar = get_wap_pager($num, $page_num, $page, 'comment.php?g_id='.$goods_id, 'page');
- $smarty->assign('pagebar' , $pagebar);
- }
- $smarty->assign('footer', get_footer());
- $smarty->display('comment.html');
- ?>
复制代码 |
WAP版模版不完整。ECSHOP学习资料:http://www.phpally.com |
ding。。。。! |
按下代码修改就可以了
V2.7.3测试: http://www.sepor.cn/mobile/comment.php?g_id=1156- <?php
- /**
- * ECSHOP WAP评论页
- * ============================================================================
- * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
- * 网站地址: http://www.ecshop.com;
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * $Author: testyang $
- * $Id: comment.php 15013 2008-10-23 09:31:42Z testyang $
- */
- define('IN_ECS', true);
- require(dirname(__FILE__) . '/includes/init.php');
- $goods_id = !empty($_GET['g_id']) ? intval($_GET['g_id']) : exit();
- if ($goods_id <= 0)
- {
- exit();
- }
- /* 读取商品信息 */
- $_LANG['kilogram'] = '千克';
- $_LANG['gram'] = '克';
- $_LANG['home'] = '首页';
- $smarty->assign('goods_id', $goods_id);
- $goods_info = get_goods_info($goods_id);
- $goods_info['goods_name'] = encode_output($goods_info['goods_name']);
- $goods_info['goods_brief'] = encode_output($goods_info['goods_brief']);
- $smarty->assign('goods_info', $goods_info);
- $page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
- /* 读评论信息 */
- $comment = assign_comment($goods_id, 'comments',$page);
- $num = $comment['pager']['record_count'];
- if ($num > 0)
- {
- $page_num = !empty($GLOBALS['_CFG']['comments_number']) ? $GLOBALS['_CFG']['comments_number'] : 5;
- $pages = ceil($num / $page_num);
- if ($page <= 0)
- {
- $page = 1;
- }
- if ($pages == 0)
- {
- $pages = 1;
- }
- if ($page > $pages)
- {
- $page = $pages;
- }
- $i = 1 + ($page-1)*$page_num;
- foreach ($comment['comments'] as $key => $data)
- {
- if (($i > ($page_num * ($page - 1 ))) && ($i <= ($page_num * $page)))
- {
- $re_content = !empty($data['re_content']) ? encode_output($data['re_content']) : '';
- $re_username = !empty($data['re_username']) ? encode_output($data['re_username']) : '';
- $re_add_time = !empty($data['re_add_time']) ? substr($data['re_add_time'], 5, 14) : '';
- $comment_data[] = array('i' => $i , 'content' => encode_output($data['content']) , 'username' => encode_output($data['username']) , 'add_time' => substr($data['add_time'], 5, 14) , 're_content' => $re_content , 're_username' => $re_username , 're_add_time' => $re_add_time);
- }
- $i++;
- }
- $smarty->assign('comment_data', $comment_data);
- $pagebar = get_wap_pager($num, $page_num, $page, 'comment.php?g_id='.$goods_id, 'page');
- $smarty->assign('pagebar' , $pagebar);
- }
- $smarty->assign('footer', get_footer());
- $smarty->display('comment.html');
- ?>
复制代码 |