Title1

Title2

Title3

12-3 更新記錄

一、流程


  #更新記錄
  case "op_update":
    $sn=op_update($sn);
    redirect_header("nav_m.php?op=op_show&sn={$sn}",3000,"更新資料成功!!");
  break;

二、函數

########################################
# 更新記錄
########################################
function op_update($sn="")
{
  global $mysqli;
  if(!$sn)redirect_header("index.php",3000,"更新記錄錯誤!!");

  #資料過濾
  $_POST['sn']   = intval($_POST['sn']);
  $_POST['title']  = $mysqli->real_escape_string($_POST['title']);
  $_POST['target'] = intval($_POST['target']);
  $_POST['enable'] = intval($_POST['enable']);
  $_POST['sort']   = intval($_POST['sort']);
  $_POST['url']    = $mysqli->real_escape_string($_POST['url']);

  $sql = "update `show_kind` set
          `title`  = '{$_POST['title']}' ,
          `target` = '{$_POST['target']}',
          `enable` = '{$_POST['enable']}',
          `url` = '{$_POST['url']}',
          `sort` = '{$_POST['sort']}'
          where sn='{$_POST['sn']}'";
  $mysqli->query($sql) or die(printf("Error: %s <br>".$sql, $mysqli->sqlstate));

  return $sn;
}