$arr = preg_split('//', $_POST['nor_score_all'], -1, PREG_SPLIT_NO_EMPTY);
$arr2=array();
foreach($arr as $v){
if(ord ($v)==46 || (ord ($v)>=48 && ord ($v)<=57) ){
$str.=$v;
}else{
if($k++==3){
array_push($arr2, '');
$k=0;
}
if($str!='') {
array_push($arr2, $str);
$k=0;
}
$str='';
}
}
if($str) array_push($arr2, $str);
//該班學生列表
$smb_arr=& $xscm->class_smb_arr($gc_year , $gc_seme , $gc_grad , $gc_class);
foreach($smb_arr as $key => $smb_sn){
//echo $smb_sn."==>";
//檢查該生該次平時成績紀錄是否存在
$one_nor=$xscm->one_nor_score($_POST['scm_nor_title_sn'],$smb_sn);
//tool::print_r($one_nor);
if($one_nor['scm_nor_sn']){
//已經存在,用更新的
if($one_nor['scm_nor_score']==$arr2[$key]) continue;
if($arr2[$key]==''){
$sql="update ".$xoopsDB->prefix("sxs_scorem_nor")." set scm_nor_score=NULL where smb_sn='$smb_sn' and scm_nor_title_sn='{$_POST['scm_nor_title_sn']}' ";
}else{
$sql="update ".$xoopsDB->prefix("sxs_scorem_nor")." set scm_nor_score='{$arr2[$key]}' where smb_sn='$smb_sn' and scm_nor_title_sn='{$_POST['scm_nor_title_sn']}' ";
}
}
else{
//新增一個
if($arr2[$key]=='') $sql="insert into ".$xoopsDB->prefix("sxs_scorem_nor")."(smb_sn,scm_nor_score,scm_nor_title_sn) values('$smb_sn', NULL ,'{$_POST['scm_nor_title_sn']}')";
else $sql="insert into ".$xoopsDB->prefix("sxs_scorem_nor")."(smb_sn,scm_nor_score,scm_nor_title_sn) values('$smb_sn','{$arr2[$key]}','{$_POST['scm_nor_title_sn']}')";
}
$rs=$CONN->Execute($sql) or redirect_header($pageurl, 5, mysql_error()."<br />
"._MD_SQL_ERR."<br />
$sql");
//echo $sql."<br />
";
沒有留言:
張貼留言