给产品增加了一个字段,goods_url,按照这个帖子(http://bbs.ecshop.com/thread-119955-1-1.html)的说明,添加字段成功,前台也能正常调用,但是就是在后台没法输入数据,总是显示默认数据,如附件所示。直接操作数据,能够正常输入url,前台正常调用,后台也能正常读入,但是一修改就又变成附件那样了。搞了一晚上也没搞定。下面是我的admin/goods.php的相关代码,求高手帮忙。
- /* 处理商品数据 */
- $shop_price = !empty($_POST['shop_price']) ? $_POST['shop_price'] : 0;
- $goods_url = !empty($_POST['goods_url']) ? $_POST['goods_url'] : 0;
- $market_price = !empty($_POST['market_price']) ? $_POST['market_price'] : 0;
- $promote_price = !empty($_POST['promote_price']) ? floatval($_POST['promote_price'] ) : 0;
- $is_promote = empty($promote_price) ? 0 : 1;
- $promote_start_date = ($is_promote && !empty($_POST['promote_start_date'])) ? local_strtotime($_POST['promote_start_date']) : 0;
- $promote_end_date = ($is_promote && !empty($_POST['promote_end_date'])) ? local_strtotime($_POST['promote_end_date']) : 0;
- $goods_weight = !empty($_POST['goods_weight']) ? $_POST['goods_weight'] * $_POST['weight_unit'] : 0;
- $is_best = isset($_POST['is_best']) ? 1 : 0;
- $is_new = isset($_POST['is_new']) ? 1 : 0;
- $is_hot = isset($_POST['is_hot']) ? 1 : 0;
- $is_on_sale = isset($_POST['is_on_sale']) ? 1 : 0;
- $is_alone_sale = isset($_POST['is_alone_sale']) ? 1 : 0;
- $goods_number = isset($_POST['goods_number']) ? $_POST['goods_number'] : 0;
- $warn_number = isset($_POST['warn_number']) ? $_POST['warn_number'] : 0;
- $goods_type = isset($_POST['goods_type']) ? $_POST['goods_type'] : 0;
- $give_integral = isset($_POST['give_integral']) ? intval($_POST['give_integral']) : '-1';
- $rank_integral = isset($_POST['rank_integral']) ? intval($_POST['rank_integral']) : '-1';
- $goods_name_style = $_POST['goods_name_color'] . '+' . $_POST['goods_name_style'];
- $catgory_id = empty($_POST['cat_id']) ? '' : intval($_POST['cat_id']);
- $brand_id = empty($_POST['brand_id']) ? '' : intval($_POST['brand_id']);
- $goods_img = (empty($goods_img) && !empty($_POST['goods_img_url']) && goods_parse_url($_POST['goods_img_url'])) ? htmlspecialchars(trim($_POST['goods_img_url'])) : $goods_img;
- $goods_thumb = (empty($goods_thumb) && !empty($_POST['goods_thumb_url']) && goods_parse_url($_POST['goods_thumb_url'])) ? htmlspecialchars(trim($_POST['goods_thumb_url'])) : $goods_thumb;
- $goods_thumb = (empty($goods_thumb) && isset($_POST['auto_thumb']))? $goods_img : $goods_thumb;
- /* 入库 */
- if ($is_insert)
- {
- if ($code == '')
- {
- $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
- "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
- "goods_url, " .
- "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
- "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
- "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, rank_integral)" .
- "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
- "'$brand_id', '$shop_price', '$goods_url', '$market_price', '$is_promote','$promote_price', ".
- "'$goods_url', ".
- "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
- "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
- " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', ".
- " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral')";
- }
- else
- {
- $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
- "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
- "goods_url, " .
- "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
- "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .
- "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)" .
- "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
- "'$brand_id', '$shop_price', '$goods_url', '$market_price', '$is_promote','$promote_price', ".
- "'$goods_url', ".
- "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
- "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
- " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', ".
- " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral')";
- }
- }
- else
- {
- /* 如果有上传图片,删除原来的商品图 */
- $sql = "SELECT goods_thumb, goods_img, original_img " .
- " FROM " . $ecs->table('goods') .
- " WHERE goods_id = '$_REQUEST[goods_id]'";
- $row = $db->getRow($sql);
- if ($proc_thumb && $goods_img && $row['goods_img'] && !goods_parse_url($row['goods_img']))
- {
- @unlink(ROOT_PATH . $row['goods_img']);
- @unlink(ROOT_PATH . $row['original_img']);
- }
- if ($proc_thumb && $goods_thumb && $row['goods_thumb'] && !goods_parse_url($row['goods_thumb']))
- {
- @unlink(ROOT_PATH . $row['goods_thumb']);
- }
- $sql = "UPDATE " . $ecs->table('goods') . " SET " .
- "goods_name = '$_POST[goods_name]', " .
- "goods_name_style = '$goods_name_style', " .
- "goods_sn = '$goods_sn', " .
- "cat_id = '$catgory_id', " .
- "brand_id = '$brand_id', " .
- "shop_price = '$shop_price', " .
- "goods_url = '$goods_url', " .
- "market_price = '$market_price', " .
- "is_promote = '$is_promote', " .
- "promote_price = '$promote_price', " .
- "promote_start_date = '$promote_start_date', " .
- "promote_end_date = '$promote_end_date', ";
- /* 如果有上传图片,需要更新数据库 */
- if ($goods_img)
- {
- $sql .= "goods_img = '$goods_img', original_img = '$original_img', ";
- }
- if ($goods_thumb)
- {
- $sql .= "goods_thumb = '$goods_thumb', ";
- }
- if ($code != '')
- {
- $sql .= "is_real=0, extension_code='$code', ";
- }
- $sql .= "keywords = '$_POST[keywords]', " .
- "goods_brief = '$_POST[goods_brief]', " .
- "seller_note = '$_POST[seller_note]', " .
- "goods_weight = '$goods_weight'," .
- "goods_url = '$goods_url'," .
- "goods_number = '$goods_number', " .
- "warn_number = '$warn_number', " .
- "integral = '$_POST[integral]', " .
- "give_integral = '$give_integral', " .
- "rank_integral = '$rank_integral', " .
- "is_best = '$is_best', " .
- "is_new = '$is_new', " .
- "is_hot = '$is_hot', " .
- "is_on_sale = '$is_on_sale', " .
- "is_alone_sale = '$is_alone_sale', " .
- "goods_desc = '$_POST[goods_desc]', " .
- "last_update = '". gmtime() ."', ".
- "goods_type = '$goods_type' " .
- "WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1";
- }
- $db->query($sql);
复制代码 |