session_start(); include "sql.php"; $id=$_GET['id']; $sql_now = "SELECT * FROM tbl_journal WHERE cat_id = '20150708123431114' AND status = 1 ORDER BY publish_date desc limit 1"; $re_now = mysql_query($sql_now); $sql_dusita = "SELECT * FROM tbl_journal WHERE cat_id = '20150624133051833' AND status = 1 ORDER BY publish_date desc limit 1"; $re_dusita = mysql_query($sql_dusita); $sql_movie = "SELECT * FROM tbl_news WHERE newscat_id = 20140506140923687 AND status = 1 ORDER BY publish_date desc limit 1"; $re_movie = mysql_query($sql_movie); $sql_more = "SELECT * FROM tbl_news WHERE news_id != $id AND status = 1 ORDER BY create_date desc limit 4"; $re_more = mysql_query($sql_more); if($id==""){ $strSQL = "SELECT * FROM tbl_journal WHERE status = 1"; }else{ $strSQL = "SELECT * FROM tbl_journal,tbl_category WHERE tbl_journal.cat_id = '$id' AND tbl_journal.status = 1 AND tbl_journal.cat_id = tbl_category.cat_id"; } $objQuery = mysql_query($strSQL); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 25; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } if($Page>$Num_Pages){ $Page_Start=(($Num_Pages*$Per_Page)-$Per_Page); $Page=$Num_Pages; } $strSQL .=" ORDER BY publish_date desc LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?>