標題:
相簿顯示 SQL問題
[打印本頁]
作者:
phpc120
時間:
2014-11-25 19:23
標題:
相簿顯示 SQL問題
<?php
header("Content-Type: text/html; charset=utf-8");
include_once("sql_connect.php");
include_once("my_msg.php");
//預設每頁筆數
$pageRow_records = 8;
//預設頁數
$num_pages = 1;
//若已經有翻頁,將頁數更新
if (isset($_GET['page'])) {
$num_pages = $_GET['page'];
}
$album_owner = $_COOKIE['cookie_id'];
echo $album_owner;
//本頁開始記錄筆數 = (頁數-1)*每頁記錄筆數
$startRow_records = ($num_pages -1) * $pageRow_records;
//未加限制顯示筆數的SQL敘述句
/*$query_RecAlbum = "SELECT `album`.`album_id` , `album`.`album_date` , `album`.`album_location` ,
`album`.`album_title` , `album`.`album_desc` , `albumphoto`.`ap_picurl`,
count( `albumphoto`.`ap_id` ) AS `albumNum` FROM `album` LEFT JOIN `albumphoto`
ON `album`.`album_id` = `albumphoto`.`album_id` WHERE `album`.`album_owner` = `$album_owner` GROUP BY `album`.`album_id` ,
`album`.`album_date` , `album`.`album_location` , `album`.`album_title` , `album`.`album_desc`
ORDER BY `album_date` DESC " ;*/
$query_RecAlbum = "SELECT `album`.`album_id` , `album`.`album_date` , `album`.`album_location` ,
`album`.`album_title` , `album`.`album_desc` , `albumphoto`.`ap_picurl`,
count( `albumphoto`.`ap_id` ) AS `albumNum` FROM `album` LEFT JOIN `albumphoto`
ON `album`.`album_id` = `albumphoto`.`album_id` where `album`.`album_owner` = $album_owner GROUP BY `album`.`album_id` ,
`album`.`album_date` , `album`.`album_location` , `album`.`album_title` , `album`.`album_desc`
ORDER BY `album_date` DESC " ;
//加上限制顯示筆數的SQL敘述句,由本頁開始記錄筆數開始,每頁顯示預設筆數
$query_limit_RecAlbum = $query_RecAlbum." LIMIT ".$startRow_records.", ".$pageRow_records;
//以加上限制顯示筆數的SQL敘述句查詢資料到 $RecAlbum 中
$RecAlbum = mysql_query($query_limit_RecAlbum);
//以未加上限制顯示筆數的SQL敘述句查詢資料到 $all_RecAlbum 中
$all_RecAlbum = mysql_query($query_RecAlbum) ;
//計算總筆數
$total_records = mysql_num_rows($all_RecAlbum) or die(mysql_error());
//計算總頁數=(總筆數/每頁筆數)後無條件進位。
$total_pages = ceil($total_records/$pageRow_records);
?>
複製代碼
錯誤顯示
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sample\demo1\index.php on line 37
Unknown column 'aaa' in 'where clause'
該行的程式碼
$total_records = mysql_num_rows($all_RecAlbum) or die(mysql_error());
總共3個帳號
只有一個可以正常顯示
其他兩個帳號都會顯示上面的錯誤
再猜是不是query那邊的問題嗎?
有請各位大大幫忙了
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)