|
|
|
มีปัญหาในการแบ่งเพจอ่าค่ะ คือ แบ่งแล้ว หน้าที่ 2ประเภท มันไม่ยอมออก อ่ะค่ะ |
|
|
|
|
|
|
|
แบ่งหน้า แล้ว ประภทสินค้า ออกแค่น้าแรก อ่ะค่ะ รบกวนดูให้หน่อยนะค่ะ
Code (PHP)
<? ob_start(); ?>
<?php
session_start();
include("include/paging.inc.php");
$i=$_GET['page'];
?>
<html>
<head>
<title>บทความ</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
body{
background-image: url(pic/bg-body.jpg);
}
</style>
<link rel="stylesheet" type="text/css" href="include/style.css" />
<script type="text/javascript" src="ajax/ajaxlogin.js"></script>
<script type="text/javascript">
function exitOUT() {
if(!confirm('คุณ <?=$_SESSION[kuuipo];?> ต้องการออกจากระบบ ?')){
return;
}
doExit('<?=$_SESSION[kuuipo];?>','LOGOUT');
}
</script>
</head>
<body>
<table width="940" height="120" align="center" background="pic/bg-header.jpg">
<tr valign="bottom">
<th width="200" align="center" valign="middle" scope="col"><a href="index.html"><img src="pic/logo.gif" alt="" width="190" height="100" border="0"></a></th>
<th align="center" scope="col"><a href="index.php">HOME</a></th>
<?php if (isset($_SESSION['kuuipo'])) {
echo " <th align=center scope=col><a href=update.php?tuser=$_SESSION[kuuipo]>Account settings</a></th>"?>
<?php }else{ ?>
<th align="center" scope="col"><a href="register.php">REGISTER</a></th>
<?php } ?>
<th align="center" scope="col"><a href="articles.php?type=1">HTML</a></th>
<th align="center" scope="col"><a href="articles.php?type=2">JAVA SCRIPT </a></th>
<th align="center" scope="col"><a href="articles?type=3&page=<? echo $i; ?>">CSS</a></th>
<th align="center" scope="col"><a href="articles.php?type=4&page=<? echo $i; ?>">WEB DESIGN </a></th>
</tr>
</table>
<div align="center"><img src="pic/separator.jpg" width="960" height="2" align="top"> </div>
<table width="940" align="center" background="pic/bg-body.jpg">
<tr>
<td align="right" scope="col">
<form name="form1" method="post" action="">
<?php
if (isset($_SESSION['kuuipo'])) {
echo "<div id=\login_table\"></div>";
echo "<tr><td align=center>ยินดีต้อนรับ<br>คุณ <strong><font color=red>$_SESSION[kuuipo]</font></strong> เข้าสู่ระบบ";
echo "
<input type=submit name=submit value=ออกจากระบบ OnClick=\"return exitOUT()\"/>
</td></tr>";
} else {
echo "<tr><td align=center colspan=2><div id=\"login_table\"></div></td></tr>";
echo "<tr><td align=right>Login :<input size=15 type=text name=login id=login maxlength=15>";
echo "Password :<input size=15 type=password name=password1 id=password1 maxlength=15>";
echo "<input type=submit name=submit value=เข้าสู่ระบบ
OnClick=\"return check_login(form1.login.value, form1.password1.value, 'LOGIN')\"/></td></tr>";
}
?>
</form>
</td>
</tr>
<?
if (isset($_SESSION['kuuipo'])) {
include "include/Contact.php";
$current_page = 1;
if(isset($_GET['page'])) {
$current_page = $_GET['page'];
}
$rows_per_page = 5 ;
$start_row = paging_start_row($current_page, $rows_per_page);
$sql = "select sql_calc_found_rows * from article where Type='$type'
limit $start_row, $rows_per_page;";
$result = mysql_query($sql);
$found_rows = mysql_query("select found_rows();");
$total_rows = mysql_result($found_rows, 0, 0);
if($total_rows == 0) {
echo "<caption><b>ไม่พบราย</b></caption>";
}
else {
$stop_row = paging_stop_row($start_row, $rows_per_page, $total_rows);
echo "<caption><b>รายการบทความ: " . ($start_row + 1) .
" - " . "$stop_row จากทั้งหมด $total_rows </b></caption>";
}?>
<tr background="pic/bg-body.jpg">
<td scope="col"><p> </p>
<?php
$type=$_GET['type'];
if($type==1){
echo"<p align=center><strong>HTML</strong></p>";
}else if($type==2){
echo"<p align=center><strong>JAVA SCRIPT</strong></p>";
}else if($type==3){
echo"<p align=center><strong>Css</strong></p>";
}else if($type==4){
echo"<p align=center><strong>WEB DESIGN</strong></p>";
}else{"งง";}?>
<? while($p = mysql_fetch_array($result)) {
$id=$p['Id_article'];
$title=$p['Title'];
$descr=$p['Descr'];
$story=$p['Story'];
echo "<p>$title</p>";
echo "<p>$detaile</p>";
echo "<a href=detail_article.php?Id=$id>อ่านต่อ </a>";
}
?>
<? $page_range = 5;
$qry_str = "";
$total_pages = paging_total_pages($total_rows, $rows_per_page);
$pagenum = paging_pagenum($current_page, $total_pages,$page_range, $qry_str);
echo "<br>หน้า: " .$pagenum;
}else{ echo "<div align=center>";
echo "<a href=register.php>กรุณาสมัครสมาชิก</a>";
echo "</div>";}?>
</td>
</tr>
</table>
</body>
</html>
หน้าแบ่เพจนะค่ะ
Code (PHP)
<? ob_start(); ?>
<?php
$type=$_GET["type"];
header("content-Type:text/html; charset=utf-8");
function paging_start_row($current_page, $rows_per_page) {
return ($current_page - 1) * $rows_per_page;
}
function paging_stop_row($start_row, $rows_per_page, $total_rows) {
return (($start_row + $rows_per_page) < $total_rows) ? ($start_row + $rows_per_page) : $total_rows;
}
function paging_total_pages($total_rows, $rows_per_page) {
return ceil($total_rows / $rows_per_page);
}
function paging_pagenum($current_page, $total_pages, $page_range, $query_string) {
$page_start = $current_page - $page_range;
$page_end = $current_page + $page_range;
if($page_start < 1) {
$page_end += 1 - $page_start;
$page_start = 1;
}
if($page_end > $total_pages) {
$diff = $page_end - $total_pages;
$page_start -= $diff;
if($page_start < 1) {
$page_start = 1;
}
$page_end = $total_pages;
}
$url = $_SERVER['PHP_SELF'] . "? " . $query_string."&".$type;
$result = "";
if($current_page > 1) {
$page = $current_page - 1;
$result .= " ";
$result .= "<a href=\"$url&page=$page\">Back</a>";
}
if($page_start > 1) {
$page = $page_start - 1;
$result .= " ";
$result .= "<a href=\"$url&page=$page\">...</a>";
}
for($i = $page_start; $i <= $page_end; $i++) {
$result .= " ";
if($i == $current_page) {
$result .= $i;
}
else {
$result .= "<a href=\"$url&page=$i&type=$type\">$i</a>";
}
$result .= " ";
}
if($page_end < $total_pages) {
$page = $page_end + 1;
$result .= " ";
$result .= "<a href=\"$url&page=$page\">...</a>";
}
if($current_page < $total_pages) {
$page = $current_page + 1;
$result .= " ";
$result .= "<a href=\"$url&page=$page\">Next</a>";
}
if($result == "") {
return "1";
}
else {
return $result;
}
}
?>
Tag : PHP, MySQL, HTML/CSS
|
|
|
|
|
|
Date :
2012-03-11 07:59:04 |
By :
kuuipo |
View :
1109 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|