Title1

Title2

Title3

18-2 op_list()函數


########################################
# 列表
########################################
function op_list()
{
  global $mysqli,$smarty,$TBL;

  #取得所有記錄
  $sql = "select *
          from `{$TBL['name']}`
          order by `sort` desc";//die($sql);
  $result = $mysqli->query($sql) or die(printf("Error: %s <br>".$sql, $mysqli->sqlstate));

  $rows=array();
  $col_name = "prod";//圖片資料表的關鍵字
  while($row = $result->fetch_assoc())
  {
    #過濾撈出資料
    $row['sn'] = intval($row['sn']);
    //http://www.w3school.com.cn/php/func_string_htmlspecialchars.asp
    $row['title'] = htmlspecialchars($row['title'], ENT_QUOTES); // 轉換雙引號和單引號
    $row['sort'] = intval($row['sort']);
    $row['enable'] = $row['enable'] ? "是":"<span style='color:red;'>否</span>";
    $row['price'] = intval($row['price']);
    $row['counter'] = intval($row['counter']);
    $row['date'] = intval($row['date']);//日期是以時間戳記儲存
    $row['date'] = date("Y-m-d",$row['date']);//http://www.w3school.com.cn/php/php_date.asp
    #取得圖片src
    $row['file_name'] = get_file_name_src($row['sn'],$col_name);

    $rows[]= $row;
  }

  $smarty->assign("rows", $rows);
  return;
}