|
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_News = 5;
$pageNum_News = 0;
if (isset($_GET['pageNum_News'])) {
$pageNum_News = $_GET['pageNum_News'];
}
$startRow_News = $pageNum_News * $maxRows_News;
mysql_select_db($database_News, $News);
$query_News = "SELECT * FROM articletitle";
$query_limit_News = sprintf("%s LIMIT %d, %d", $query_News, $startRow_News, $maxRows_News);
$News = mysql_query($query_limit_News, $News) or die(mysql_error());
$row_News = mysql_fetch_assoc($News);
if (isset($_GET['totalRows_News'])) {
$totalRows_News = $_GET['totalRows_News'];
} else {
$all_News = mysql_query($query_News);
$totalRows_News = mysql_num_rows($all_News);
}
$totalPages_News = ceil($totalRows_News/$maxRows_News)-1;
mysql_select_db($database_News, $News); //有問題的53行
$query_catalog = "SELECT * FROM `catalog`";
$catalog = mysql_query($query_catalog, $News) or die(mysql_error()); //有問題的55行
$row_catalog = mysql_fetch_assoc($catalog);
$totalRows_catalog = mysql_num_rows($catalog);
//***** PHP中限制文字顯示自訂函式開始 *****
function cutword($cutstring,$cutno){
if(strlen($cutstring) > $cutno) {
for($i=0;$i<$cutno;$i++) {
$ch=substr($cutstring,$i,1);
if(ord($ch)>127) $i++;
}
$cutstring= substr($cutstring,0,$i)."...";
}
return $cutstring;
}
//***** PHP中限制文字顯示自訂函式結束 *****
?> |