|
|
|
อยากสอบถามเรื่องการแบ่งหน้าหน่อยครับ พอดีลองทำแล้วครับแต่เลขหน้ามันเย้อะมาก |
|
|
|
|
|
|
|
ตัวอย่างโค้ดครับ (ขอโทษด้วยครับที่มันยาว และยุ่งเหยิงไปหน่อย)
Code (PHP)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<TITLE>คำศัพท์เทคนิค</TITLE>
<META content="Programming, CGI, Perl, PHP, JavaScript, Java, Active Server Pages, ASP, C, C++, Developer, Web Development"
name=keywords>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<META content="iNET Interactive, LLC" name=Author>
<META content=2004-10-27 name=Date>
<META content="1998-2004 iNET Interactive, LLC" name=Copyright>
<META http-equiv=Expires content="Sat, 1 Jan 2000 00:00:00 GMT">
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Cache-Control content=no-cache>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="INDEX, FOLLOW" name=robots>
<LINK href="../s1.css" type=text/css rel=stylesheet>
<LINK href="../s2.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE type=text/css>
.networkbarselect {
FONT-SIZE: 11px; COLOR: #333333; FONT-FAMILY: Arial, Helvetica, sans-serif; BACKGROUND-COLOR: #f2f2f2
}
.today { font-family: ms sans serif; font-size: 10pt;
font-weight: bold; background-color: #FAE1EA;
color: #000000; border: 0 double #000000; }
.sunday { font-family: ms sans serif; font-size: 10pt;
background-color: #FB0B12; color: #FFFFFF; }
.norm { font-family: ms sans serif; font-size: 10pt;
background-color: #FFFFFF; color: #000000; }
.event { font-family: ms sans serif; font-size: 10pt;
background-color: #FFFF66; color: #000000; }
a:link {
color: 751316;
}
a:visited {
color: 751316;
}
a:hover {
color: #FF9900;
}
a:active {
color: #003399;
}
body {
background-image: url(img/bg1.gif);
}
.style5 {font-size: 14px}
</STYLE>
<script language="JavaScript">
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
</script>
</HEAD>
<BODY text="#000099" leftMargin=0 topMargin=0 marginwidth="0" marginheight="0" onLoad="start();">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><TABLE width=800 border=0 align=center cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD colspan="4" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><img src="img/file_01.gif" width="100%" height="136"></td>
</tr>
</table> </TD>
</TR>
<TR valign="top">
<TD colspan="5" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" align="left" valign="top">
<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
<tr align="left" valign="top">
<td width="13%" height="20" align="center" valign="middle" background="img/btad.gif"><a href="logar.php" target="_blank">เพิ่ม/แก้ไขคำศัพท์</a></td>
<td width="7%" align="left" valign="middle" background="img/btad.gif"> </td>
<td width="38%" align="left" valign="middle" background="img/btad.gif"> </td>
<td width="12%" align="center" valign="middle" background="img/btad.gif"><!--<a href="mapr2.php" target="_blank">--><!--</a>--></td>
<td width="13%" align="center" valign="middle" background="img/btad.gif"><a href="http://www.lamptech.ac.th/phpdept/main/show.php?idcat=604" target="_blank">Education Hub</a></td>
<td width="7%" align="center" valign="middle" background="img/btad.gif"><a href="คำสั่งแต่งตั้ง 25 ศัทพ์ภาษาอังกฤษ.pdf" target="_blank">คำสั่ง</a></td>
<td width="10%" align="center" valign="middle" background="img/btad.gif"><a href="logar_admin.php" target="_blank"><img src="img/Admin.jpg" border="0" ></a></td>
</tr>
</table></td>
</tr>
</table></TD>
</TR>
<TR valign="top">
<TD colspan="5" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="68" align="left" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="68" align="center" valign="center"><img src="img/CMU.jpg"></td>
</tr>
</table></td>
</tr>
</table></TD>
</TR>
<td align="left" valign="top"><form action="searchar3.php" method="post" name="SearchForm" id="SearchForm" onSubmit="return check()" target="_blank">
<table width="100%" border="0">
<tr>
<td align="center" valign="top"><img src="img/search.png"> รหัสวิชา
<input type="text" name="search2" size="9" maxlength="9" height="20" >
<input name="submit" type="submit" value=" ตกลง " border="1">
</td>
</tr>
</table>
</form></td>
<td align="left" valign="top"></td>
<TR valign="top">
<TD colspan="5" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><?
include("config.inc.php");
$chk_date = date("j M Y",mktime( date("H")+$p_hour, date("i")+$p_min ));
if (empty($page)){
$page=1;
}
// ติดต่อ database เพื่ออ่านข้อมูล
mysql_connect($host,$user,$passwd);
//$sql="SELECT article.no_ar, article.title_ar, article.file_ar, article.date_ar,article.pak , article.term_ar, article.user_ar, article.count_ar, article.term, article.YEAR, webboard_member.Call, webboard_member.NAME_USER, webboard_member.LAST, webboard_member.ID_DEPT1, webboard_member.ID_USER1, dept.NAME_DEPT, dept.ID_DEPT _
//FROM (webboard_member INNER JOIN article ON webboard_member.ID_USER1 = article.user_ar) INNER JOIN dept ON webboard_member.ID_DEPT1 = dept.ID_DEPT";
$sql="SELECT * from article order by vocab ASC ";
$result = mysql_db_query($dbname,$sql);
$NRow = mysql_num_rows($result);
$counter_vocab = $NRow;
$rt = $NRow%$list_page;
if($rt!=0) {
$totalpage = floor($NRow/$list_page)+1;
}
else {
$totalpage = floor($NRow/$list_page);
}
$goto = ($page-1)*$list_page;
//เลือกแสดงข้อมูลเฉพาะบุคคล
//$sql="SELECT article.no_ar, article.title_ar, article.file_ar, article.date_ar, article.user_ar,article.pak ,article.term_ar,article.count_ar, article.term, article.YEAR, webboard_member.Call, webboard_member.NAME_USER, webboard_member.LAST, webboard_member.ID_DEPT1, webboard_member.ID_USER1, dept.NAME_DEPT, dept.ID_DEPT _
//FROM (webboard_member INNER JOIN article ON webboard_member.ID_USER1 = article.user_ar) INNER JOIN dept ON webboard_member.ID_DEPT1 = dept.ID_DEPT order by no_ar DESC limit $goto,$list_page";
$sql="SELECT * from article order by vocab ASC limit $goto,$list_page";
$result = mysql_db_query($dbname,$sql);
$NRow = mysql_num_rows($result);
if($NRow==0) {
echo "<font size=2 face='MS Sans Serif'>ยังไม่มีข้อมูล</font><br><br>\n";
}
// แสดงหัวข้อของบอร์ด
else {
echo "<table width=100% border=1 bordercolor=eeeeee cellspacing=0 cellpadding=2>\n";
echo "<tr bgcolor= 751316>\n";
echo "\t<td align=center width=3%><font size=2 color=eeeeee><b>ลำดับ </b></font></td>\n";
echo "\t<td align=center width=18%><font size=2 color=eeeeee><b>คำศัพท์</b></font></td>\n";
echo "\t<td align=center width=18%><font size=2 color=eeeeee><b>คำอ่าน</b></font></td>\n";
echo "\t<td align=center width=18%><font size=2 color=eeeeee><b>ความหมาย</b></font></td>\n";
echo "\t<td align=center width=6%><font size=2 color=eeeeee><b>ลักษณะ</b></font></td>\n";
echo "\t<td align=center width=9%><font size=2 color=eeeeee><b>ชื่อ</b></font></td>\n";
echo "\t<td align=center width=8%><font size=2 color=eeeeee><b>รหัสวิชา</b></font></td>\n";
echo "</tr>\n\n";
// วนลูปแสดงข้อมูลที่อ่านได้
// for( $p=1; $p<=$rt ;$p++) //แสดงจำนวนผลงาน
//{
$p=(($page-1)*30 +$p)+1;
while ($row = mysql_fetch_array($result)) {
// กำหนดสีของตาราง เพื่อให้มีการสลับสี
$bgc = ($bgc=="FFF1B6") ? "FBF6E1" : "FFF1B6";
// กำหนดค่าตัวแปร เพื่อนำไปแสดง
$no_ar=$row["no_ar"];
$p_subject =$row["p_subject"];
$title_ar = $row["title_ar"];
$date_ar = $row["date_ar"];
$user_ar= $row["user_ar"];
$saka= $row["saka"];
$saka= $row["saka"];
$year= $row["year"];
$term = $row["term"];
$vocab = $row["vocab"];
$reads = $row["reads"];
$mean = $row["mean"];
$noun = $row["noun"];
$nickname = $row["nickname"];
//แสดงข้อมูลในตาราง
echo "<tr bgcolor=$bgc>\n";
echo "\t<td align=center ><font size=2 color=751316>$p</font></td>\n";
echo "\t<td align=left ><font size=2 color=751316>$vocab</font></td>\n";
echo "\t<td align=left ><font size=2 color=751316>$reads</font></td>\n";
echo "\t<td align=left ><font size=2 color=751316>$mean</font></td>\n";
echo "\t<td align=center ><font size=2 color=751316>$noun</font></td>\n";
echo "\t<td align=center ><font size=2 color=751316>$nickname</font></td>\n";
echo "\t<td align=center ><font size=2 color=751316>$p_subject </font></td>\n";
echo "\t<tr bgcolor>\n";
$p=$p+1;
}
// table แสดงเลขหน้า
echo "<table width=100% border=0 bgcolor=FFFFFF bordercolor=black cellspacing=0 cellpadding=2>\n";
echo "<tr><td align=center>\n";
echo "\t<font size=2 color=#751316>\n";
// สร้าง link เพื่อไปหน้าก่อน-หน้าถัดไป
if($page>1 && $page<=$totalpage) {
$prevpage = $page-1;
echo "\t<a href='index.php?page=$prevpage'>[หน้าก่อน = $prevpage]</a>\n";
}
echo "\t กำลังแสดงหน้าที่ $page จากทั้งหมด $totalpage หน้า\n";
if($page!=$totalpage) {
$p=30;
$nextpage = $page+1;
echo "\t<a href='index.php?page=$nextpage'>[หน้าถัดไป = $nextpage]</a><br>\n";
echo "มีคำศัพท์อยู่ในระบบทั้งหมด ";
echo $counter_vocab;
echo " คำ";
}
echo "\t</font>\n";
echo "</td></tr>\n";
echo "<tr><td>\n";
// วนลูปแสดงเลขหน้าทั้งหมด
for($i=1 ; $i<$page ; $i++) {
echo "\t<a href='index.php?page=$i'>$i</a> \n";
}
//echo "\t<font size=2 color=751316><b>$page</b></font> \n";
for($i=$page+1 ; $i<=$totalpage ; $i++) {
echo "\t<a href='index.php?page=$i'>$i</a> \n";
}
echo "</td></tr>\n";
echo "</table>\n";
}
?></td>
</tr>
</table>
</TD>
</TR>
<TR>
<TD colspan="4" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top"><table width="100%" height="41" >
<tr>
<td height="35" align="left" valign="top"><form action="searchar.php" method="post" name="SearchForm" id="SearchForm" onSubmit="return check()" target="_blank">
<table width="100%" border="0">
<tr>
<td align="center" valign="top"><span class="style5"> <img src="img/search.png"> คำศัพท์</span>
<input type="text" name="search" size="25" maxlength="100" height="20" >
<input name="submit" type="submit" value=" ตกลง " border="1"> </td>
</tr>
</table>
</form></td>
<td align="left" valign="top"><form action="searchar2.php" method="post" name="SearchForm" id="SearchForm" onSubmit="return check()" target="_blank">
<table width="100%" border="0">
<tr>
<td align="center" valign="top"><span class="style5"><img src="img/search.png"> แผนก/สาขา</span>
<select name="uid2" size="-1" >
<option value=""> -------- เลือกแผนก/สาขา --------- </option>
<?php
include("config.inc.php");
$chk_date = date("j M Y",mktime( date("H")+$p_hour, date("i")+$p_min ));
mysql_connect($host,$user,$passwd);
$sql="select * from geography order by GEO_ID ASC";
$result = mysql_db_query($dbname,$sql);
$NRow = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$GEO_ID= $row["GEO_ID"];
$GEO_NAME= $row["GEO_NAME"];
?>
<option value="<?=$row["GEO_NAME"]?>">
<?=$row["GEO_NAME"]?>
</option>
<?php
}
?>
</select>
<input name="submit" type="submit" value=" ตกลง " border="1"> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<table width="100%" >
<tr>
<td height="35" align="left" valign="top"><form action="search_mean.php" method="post" name="SearchForm" id="SearchForm2" onSubmit="return check()" target="_blank">
<table width="100%" border="0">
<tr>
<td align="center" valign="top"><span class="style5"><img src="img/search.png"></span> ความหมาย
<input type="text" name="search_mean" size="25" maxlength="100" height="20" >
<input name="submit2" type="submit" value=" ตกลง " border="1">
</td>
</tr>
</table>
</form>
</td>
<td align="left" valign="top"><form action="search_name.php" method="post" name="SearchForm" id="SearchForm2" onSubmit="return check()" target="_blank">
<table width="100%" border="0">
<tr>
<td align="center" valign="top"><span class="style5"><img src="img/search.png"></span> ชื่ออาจารย์
<input type="text" name="search_name" size="25" maxlength="100" height="20" >
<input name="submit2" type="submit" value=" ตกลง " border="1">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table> <p><img src=img/icon_43.jpg width="50" height="26" border=0></b><b>
<?
$wantcount = true;
$counter_file = "count/counter.txt";
if($wantcount)
{
if (file_exists($counter_file) and is_writeable($counter_file))
{
$fp = fopen($counter_file,"r+") or die("Read File Error !");
$count = fread($fp, filesize($counter_file));
fclose($fp);
$fp = fopen($counter_file,"w+") or die("Write File Error !");
//$count +=1;
fputs($fp, $count);
fclose($fp);
//echo "<font face='Arial' color='#990000'><b>".$count."</b></font>";
}
}
?>
<?
function imgcount($txt)
{
for ($i=0;$i<10;$i++) {
$txt = ereg_replace("$i", "<img src='count/$i.GIF'>", $txt);
//echo "<img src='../count/$i.GIF'>";
}
return ($txt);}
?>
<? echo imgcount($count);?></b><b></b></p></td>
</tr>
</table></TD>
</TR>
<TR>
<TD colspan="4" align="left" valign="top"><table cellspacing=0 cellpadding=0 width=100% border=0>
<tbody>
<tr> </tr>
<tr>
<td
height=30 align=middle valign=center><img src="img/foot.gif" width="100%" height="50"></td>
</tr>
<tr> </tr>
</tbody>
</table></TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
</table></td>
</tr>
</table>
</BODY></HTML>
คือว่าตอนนี้ต้องการอยากจะแก้ให้ได้แบบนี้อ่ะครับ แบบแสดงเป็นชุดๆครับ ตอนนี้มันยาวมากเลย
back 1 2 3 4 5 next
back 5 6 7 8 9 10 next
เคยลองเอาของพี่ PlaKriM ไปแกะดูก็มึนครับไม่สำเร็จ 555
ยังงัยช่วยแนะนำหน่อยนะครับ ขอบคุณมากครับ
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2010-09-29 14:15:43
|
|
|
|
|
Date :
2010-09-29 14:10:05 |
By :
topchai |
View :
992 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบไม่ได้ ตาลาย
|
|
|
|
|
Date :
2011-04-08 01:09:44 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|