PHP代码和模板的调用对应起来不出错
程序员文章站
2022-06-09 13:22:45
...
$paralist = $db ->row_select('selfdefine',"isshow=1",' id,type_name,type_value,c_name');if ($ac == 'add') {$post['p_hits'] = 0;$post['p_addtime'] = time();$post['listtime'] = time();$post['isshow'] = 1;$post['issell'] = 0;$post['uid'] = -1;$rs = $db ->row_insert('cars',$post);$post=post('c_id','p_id','c_value');$insertid = $db ->insert_id();foreach($paralist as $key =>$value){$post['c_id']=$paralist[$key]['id'];$post['p_id']=$insertid;$c_value='para'.$key;if($paralist[$key]['type_name']=='checkbox'){$checkpara = implode("|",$_POST[$c_value]);$post['c_value'] = $checkpara;}else{$post['c_value'] = $_POST[$c_value];}$r = $db ->row_insert('selfdefine_value',$post);}html_cars($insertid);}else {$rs = $db ->row_update('cars',$post,"p_id=".intval($_POST['id']));$post = post('p_id','c_value');foreach($paralist as $key =>$value){$post['p_id']=intval($_POST['id']);$c_value='para'.$key;if($paralist[$key]['type_name']=='checkbox'){$checkpara = implode("|",$_POST[$c_value]);$post['c_value'] = $checkpara;}else{$post['c_value'] = $_POST[$c_value];}$selfvalue= $db ->row_select_one('selfdefine_value',"p_id=".intval($_POST['id']).' and c_id='.$paralist[$key]['id'],'c_id,p_id');if(empty($selfvalue['c_id'])){$post['c_id']=$paralist[$key]['id'];$r = $db ->row_insert('selfdefine_value',$post);}else{$rs = $db ->row_update('selfdefine_value',$post,"p_id=".intval($_POST['id']).' and c_id='.$paralist[$key]['id']);}}html_cars(intval($_POST['id']));}}else {$configure_list = array();if (empty($_GET['id'])) {$data = array('p_brand'=>'','p_subbrand'=>'','p_subsubbrand'=>'','p_name'=>'','p_allname'=>'','p_keyword'=>'','p_price'=>'','p_pics'=>'','p_color'=>'','p_country'=>'','p_transmission'=>'','p_year'=>'','p_month'=>'','p_details'=>'','p_model'=>'','p_hits'=>'','p_state'=>1,'p_gas'=>'','p_kilometre'=>'','p_addtime'=>'','listtime'=>'','issell'=>'','isshow'=>'','aid'=>'','cid'=>'','p_emission'=>'');}else {$data = $db ->row_select_one('cars',"p_id=".intval($_GET['id']));if (!empty($data['p_pics'])) {$pic_list = explode('|',$data['p_pics']);$piclist = array();foreach($pic_list as $key =>$value) {$piclist[$key]['pic'] = $value;$piclist[$key]['showpic'] = WEB_PATH .$value;$arr_picid = explode("/",$value);$arr_length = count($arr_picid);$arr_picids = explode(".",$arr_picid[$arr_length-1]);$piclist[$key]['picid'] = $arr_picids[0];}$tpl ->assign('pic_list',$piclist);}}$paralist = $db ->row_select('selfdefine',"isshow=1",' id,type_name,type_value,c_name');foreach($paralist as $key =>$value){if(!empty($data['p_id'])){$para_value = $db ->row_select_one('selfdefine_value',"p_id=".$data['p_id'].' and c_id='.$value['id']);if($value['type_name']=='select'){$arr_para = arr_selfdefine($value['type_value']);$para = select_make($para_value['c_value'],$arr_para,'请选择');$paralist[$key]['select'] = $para;}elseif($value['type_name']=='checkbox'){$check_para = explode("|",$value['type_value']);$checkvalue = explode("|",$para_value['c_value']);$checkbox_str = "";foreach($check_para as $k =>$v){if(in_array($v,$checkvalue)){$check = "checked";}else{$check = "";}$checkbox_str.= " ".$v." ";}$tpl->assign('checkbox_str',$checkbox_str);}else{$paralist[$key]['c_value']=$para_value['c_value'];}}else{if($value['type_name']=='select'){$arr_para = arr_selfdefine($value['type_value']);$para = select_make(-1,$arr_para,'请选择');$paralist[$key]['select'] = $para;}elseif($value['type_name']=='checkbox'){$check_para = explode("|",$value['type_value']);foreach($check_para as $k =>$v){$list[$check_para[$k]]=0;}$tpl->assign('list',$list);
上面的PHP代码我是源文件里截出来的,下面的是模板的代码,怎么能对应起来不出错,现在只要插入截来PHP代码就空白,也不知道代码应该从哪里开始哪里结束,麻烦知道的大哥指导下
回复讨论(解决方案)
没人回给分吧
推荐阅读