Board logo

標題: 相簿顯示 SQL問題 [打印本頁]

作者: phpc120    時間: 2014-11-25 19:23     標題: 相簿顯示 SQL問題

  1. <?php
  2. header("Content-Type: text/html; charset=utf-8");
  3.   include_once("sql_connect.php");
  4.   include_once("my_msg.php");
  5. //預設每頁筆數
  6. $pageRow_records = 8;
  7. //預設頁數
  8. $num_pages = 1;
  9. //若已經有翻頁,將頁數更新
  10. if (isset($_GET['page'])) {
  11.   $num_pages = $_GET['page'];
  12. }
  13. $album_owner =  $_COOKIE['cookie_id'];
  14. echo $album_owner;
  15. //本頁開始記錄筆數 = (頁數-1)*每頁記錄筆數
  16. $startRow_records = ($num_pages -1) * $pageRow_records;
  17. //未加限制顯示筆數的SQL敘述句
  18. /*$query_RecAlbum = "SELECT `album`.`album_id` , `album`.`album_date` , `album`.`album_location` ,
  19. `album`.`album_title` , `album`.`album_desc` , `albumphoto`.`ap_picurl`,
  20.   count( `albumphoto`.`ap_id` ) AS `albumNum` FROM `album`  LEFT JOIN `albumphoto`
  21.   ON `album`.`album_id` = `albumphoto`.`album_id` WHERE `album`.`album_owner` = `$album_owner` GROUP BY `album`.`album_id` ,
  22.    `album`.`album_date` , `album`.`album_location` , `album`.`album_title` , `album`.`album_desc`
  23.     ORDER BY `album_date` DESC " ;*/
  24. $query_RecAlbum = "SELECT `album`.`album_id` , `album`.`album_date` , `album`.`album_location` ,
  25. `album`.`album_title` , `album`.`album_desc` , `albumphoto`.`ap_picurl`,
  26.   count( `albumphoto`.`ap_id` ) AS `albumNum` FROM `album`  LEFT JOIN `albumphoto`
  27.   ON `album`.`album_id` = `albumphoto`.`album_id` where `album`.`album_owner` = $album_owner GROUP BY `album`.`album_id` ,
  28.    `album`.`album_date` , `album`.`album_location` , `album`.`album_title` , `album`.`album_desc`
  29.     ORDER BY `album_date` DESC " ;
  30. //加上限制顯示筆數的SQL敘述句,由本頁開始記錄筆數開始,每頁顯示預設筆數
  31. $query_limit_RecAlbum = $query_RecAlbum." LIMIT ".$startRow_records.", ".$pageRow_records;
  32. //以加上限制顯示筆數的SQL敘述句查詢資料到 $RecAlbum 中
  33. $RecAlbum = mysql_query($query_limit_RecAlbum);
  34. //以未加上限制顯示筆數的SQL敘述句查詢資料到 $all_RecAlbum 中
  35. $all_RecAlbum = mysql_query($query_RecAlbum)  ;
  36. //計算總筆數
  37. $total_records = mysql_num_rows($all_RecAlbum) or die(mysql_error());
  38. //計算總頁數=(總筆數/每頁筆數)後無條件進位。
  39. $total_pages = ceil($total_records/$pageRow_records);
  40. ?>
複製代碼
錯誤顯示
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/)