|
|
|
ช่วยดูโค๊ดแบ่งหน้าให้ทีทําไมผมดัดแปลงแล้วมัน error แบบนี้ครับ |
|
|
|
|
|
|
|
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\AppServ\www\keng project music\testpage.php on line 73
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\keng project music\testpage.php on line 74
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\AppServ\www\keng project music\testpage.php on line 75
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\keng project music\testpage.php on line 75
Code (PHP)
<?php
#######################################################################
# $page = (isset($_GET['page']))? intval($_GET["page"]) : 0;
# $limit_end = 20;
# $limit_start = ($page-1)*$limit_end;
# $sql = "select * from table limit " . $limit_start. "," . $limit_end;
# page_navi($page, $limit_end, 4, 1000, "_self", "current_page", "other_page", $querystring);
#######################################################################
# $page = หน้าปัจจุบัน
# $limit= จำนวน record ต่อหน้า
# $range= บวกลบจากหน้าปัจจุบัน ใส่ 4 จะได้ตัวเลขออกมา 9
# $count= จำนวน record ทั้งหมด
# $send= ส่งตัวแปรอะไรไปด้วย
# $current_style = css สำหรับหน้าปัจจุบัน
# $other_style = css สำหรับอื่นๆ รวมถึง Prev Next First Last
# $target= อันนี้รู้ๆ กัน
#######################################################################
function page_navi($page, $limit, $range, $count, $send=NULL, $current_style="navi_on", $other_style="navi_out", $target="_self"){
$output = "";
$total = ceil($count/$limit);
$navi_start = $page-$range;
$navi_end = $page+$range;
$send .= (!empty($send))? "&" : NULL;
if($navi_start <= 0) $navi_start = 1;
if($navi_end >= $total) $navi_end = $total;
if($page>1){
$navi_back = $page-1;
if($page > 2)
$output .= "<a href=\"?" . $send . "page=1\" target=\"" . $target . "\" class=\"" . $other_style . "\"><strong>«</strong></a> ";
$output .= "<a href=\"?" . $send . "page=" . $navi_back . "\" target=\"" . $target . "\" class=\"" . $other_style . "\"><strong>‹</strong></a> ";
}
for($i = $navi_start; $i <= $navi_end; $i++){
if($i == $page)
$output .= "<a href=\"?" . $send . "page=" . $i . "\" target=\"" . $target . "\" class=\"" . $current_style . "\"><strong><font color=\"" . $other_style . "\">$i</font></strong></a> ";
else
$output .= "<a href=\"?" . $send . "page=" . $i . "\" target=\"" . $target . "\" class=\"" . $other_style . "\">$i</a> ";
}
if($page < $total){
$navi_next = $page+1;
$output .= "<a href=\"?" . $send . "page=" . $navi_next . "\" target=\"" . $target . "\" class=\"" . $other_style . "\"><strong>›</strong></a> ";
if(($page+1) < $total)
$output .= "<a href=\"?" . $send . "page=" . $total . "\" target=\"" . $target . "\" class=\"" . $other_style . "\"><strong>»</strong></a>";
}
if($navi_start>$navi_end)
$output .= "<a href=\"?" . $send . "page=" . $page . "\" target=\"" . $target . "\" class=\"" . $other_style . "\"><strong>$page</strong></a> ";
return $output;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
include("connect/connect.php");
$page = (isset($_GET['page']))? intval($_GET['page']) : 1;
$limit_end = 2;
$limit_start = ($page-1)*$limit_end;
$send = "";
if(isset($_GET["id"]) and $_GET["id"] != ""){
$send = "id=" . $_GET["id"];
$condition= " WHERE music = '" . $_GET["music"] . "'";
}
$sql = "SELECT * FROM upload" . $condition;
$query_id = mysql_query($sql . " LIMIT " . $limit_start. "," . $limit_end, $connection_id);
$count = mysql_num_rows($query_id);
$total = mysql_num_rows(mysql_query($sql, $connection_id));
if($total > 0){
while($rows = mysql_fetch_assoc($query_id)){
echo $rows[" music"]."<br>";
}
echo "\n<div style=\"float:left;\">Page : " . page_navi($page, $limit_end, 4, $total, $send) . " </div><div style=\"float:right;\">[" . ($limit_start+1) . "-" . ($limit_start+$count) . "] of <strong>" . $total . "</strong></div>";
}
?>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2010-12-13 11:36:58 |
By :
kenghockey |
View :
726 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
echo mysql_query($sql . " LIMIT " . $limit_start. "," . $limit_end, $connection_id) or die(mysql_error());
ลองดู Error ว่อาะไร
|
|
|
|
|
Date :
2010-12-13 12:44:38 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|