ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¬ÛïÅã¥Ü SQL°ÝÃD

¬ÛïÅã¥Ü SQL°ÝÃD

  1. <?php
  2. header("Content-Type: text/html; charset=utf-8");
  3.   include_once("sql_connect.php");
  4.   include_once("my_msg.php");
  5. //¹w³]¨C­¶µ§¼Æ
  6. $pageRow_records = 8;
  7. //¹w³]­¶¼Æ
  8. $num_pages = 1;
  9. //­Y¤w¸g¦³Â½­¶¡A±N­¶¼Æ§ó·s
  10. if (isset($_GET['page'])) {
  11.   $num_pages = $_GET['page'];
  12. }
  13. $album_owner =  $_COOKIE['cookie_id'];
  14. echo $album_owner;
  15. //¥»­¶¶}©l°O¿ýµ§¼Æ = (­¶¼Æ-1)*¨C­¶°O¿ýµ§¼Æ
  16. $startRow_records = ($num_pages -1) * $pageRow_records;
  17. //¥¼¥[­­¨îÅã¥Üµ§¼ÆªºSQL±Ô­z¥y
  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. //¥[¤W­­¨îÅã¥Üµ§¼ÆªºSQL±Ô­z¥y¡A¥Ñ¥»­¶¶}©l°O¿ýµ§¼Æ¶}©l¡A¨C­¶Åã¥Ü¹w³]µ§¼Æ
  31. $query_limit_RecAlbum = $query_RecAlbum." LIMIT ".$startRow_records.", ".$pageRow_records;
  32. //¥H¥[¤W­­¨îÅã¥Üµ§¼ÆªºSQL±Ô­z¥y¬d¸ß¸ê®Æ¨ì $RecAlbum ¤¤
  33. $RecAlbum = mysql_query($query_limit_RecAlbum);
  34. //¥H¥¼¥[¤W­­¨îÅã¥Üµ§¼ÆªºSQL±Ô­z¥y¬d¸ß¸ê®Æ¨ì $all_RecAlbum ¤¤
  35. $all_RecAlbum = mysql_query($query_RecAlbum)  ;
  36. //­pºâÁ`µ§¼Æ
  37. $total_records = mysql_num_rows($all_RecAlbum) or die(mysql_error());
  38. //­pºâÁ`­¶¼Æ=(Á`µ§¼Æ/¨C­¶µ§¼Æ)«áµL±ø¥ó¶i¦ì¡C
  39. $total_pages = ceil($total_records/$pageRow_records);
  40. ?>
½Æ»s¥N½X
¿ù»~Åã¥Ü
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'

¸Ó¦æªºµ{¦¡½X
$total_records = mysql_num_rows($all_RecAlbum) or die(mysql_error());

Á`¦@3­Ó±b¸¹
¥u¦³¤@­Ó¥i¥H¥¿±`Åã¥Ü
¨ä¥L¨â­Ó±b¸¹³£·|Åã¥Ü¤W­±ªº¿ù»~
¦A²q¬O¤£¬Oquery¨ºÃ䪺°ÝÃD¶Ü?
¦³½Ð¦U¦ì¤j¤jÀ°¦£¤F

        ÀR«ä¦Û¦b : ®É®É¦n¤ß´N¬O®É®É¦n¤é¡C
ªð¦^¦Cªí ¤W¤@¥DÃD