0) { $all_page = (int)($x2) + 1; } else { $all_page = $x2; } # คำนวณหา record เริ่มและจบของแต่ละหน้า if ($p == 1) { $start_loop = 0; } else { $p2 = $p - 1; $start_loop = $p2 * $config_list_per_page; } # /คำนวณหา record เริ่มและจบของแต่ละหน้า # /แบ่งหน้า # # เลขหน้าสำหรับทำลิงค์ # $url_keyword = urlencode($keyword); $url_sort = urlencode($sort); for ($i=1;$i<=$all_page;$i++) { $p_temp = $p + 1; $p_temp2 = $p - 1; if ($i == 1) { if ($i == $p) { $page_link .= "[ $i ] "; } else { $page_link .= "<< Prev [ $i ] "; } } elseif ($i == $all_page) { if ($i == $p) { $page_link .= "[ $i ] "; } else { $page_link .= "[ $i ] Next >>"; } } else { if ($i == $p) { $page_link .= "[ $i ] "; } else { $page_link .= "[ $i ] "; } } } # /เลขหน้าสำหรับทำลิงค์ # $DESC = "DESC"; if (!$sort) { $sort = "ID"; } if ($sort == "NAME") { $DESC = ""; } @$db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db($config_db_name); if (!$db) { echo "Error connect to Database: " . mysql_error(); ob_end_flush(); exit; } $sql = "SELECT * FROM $config_table_program WHERE ($gen_search) ORDER BY $sort $DESC limit $start_loop,$config_list_per_page"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $DESCRIPTION = preg_replace('/\<(.|\s)*?\>/',' ',$row[DESCRIPTION]); $DESCRIPTION = preg_replace('/\<.+/',' ',$DESCRIPTION); $DESCRIPTION = substr($DESCRIPTION,0,100); $NAME = ucfirst($row[NAME]); $SIZE = Gen_File_Size($row[SIZE]); list($DATE_ADD) = split(" ", $row[DATE_ADD]); $DOWNLOAD_THIS_WEEK = Gen_Comify($row[DOWNLOAD_THIS_WEEK]); $DOWNLOAD_ALL = Gen_Comify($row[DOWNLOAD_ALL]); $DOWNLOAD_WEEK = $row[DOWNLOAD_WEEK]; $week_of_year = strftime("%W"); if ($DOWNLOAD_WEEK != $week_of_year) { $DOWNLOAD_THIS_WEEK = 0; } $flag_th = ""; if ($row[NATION] == "TH") { $flag_th = " "; } $tp[DATA] .= " $NAME$flag_th
$DESCRIPTION...
OS: $row[OS]
File Size: $SIZE
License: $row[LICENSE]
$DATE_ADD $DOWNLOAD_THIS_WEEK   $DOWNLOAD_ALL   "; } mysql_free_result($result); mysql_close($db); $tp[url_keyword] = $url_keyword; $tp[url_sort] = $url_sort; $tp[record_all] = $record_all; $tp[page_link] = $page_link; $tp[keyword] = $keyword; Template($template_search); #### end of program #### ##################################################################### #### Start sub program. Don't touch anything below #### ?>