|
 |
|
ช่วยแนะนำการวนลูปลำดับที่โดยที่ไม่ได้ดึงลำดับที่มาจากฐานข้อมูล |
|
 |
|
|
 |
 |
|
ผม งง ครับ   
|
 |
 |
 |
 |
Date :
2012-03-05 17:25:39 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<? session_start()
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
background-image: url(images/bg2-1.jpg);
background-color: #8EC6F7;
}
.style27 {font-family: "Courier New", Courier, monospace; font-size: 12px; font-weight: bold; color: #336699; }
.style31 {
color: #FFFFFF;
font-size: 13px;
}
.style35 {font-family: "Courier New", Courier, monospace; font-size: 13px; font-weight: bold; color: #FFFFFF; }
.style46 {color: #003399}
.style47 {font-family: "Courier New", Courier, monospace; font-size: 12px; color: #003399; }
.mynavi{
display:inline;
width:30px;
height:25px;
text-align:center;
text-decoration:none;margin-right:3px;
background-color:#99CC33;
color:#FFFFFF;
float:left;
font-size:12px;
line-height:20px;
}
.mynavi:hover{
display:block;
width:25px;
height:20px;
text-align:center;
text-decoration:none;margin-right:3px;
background-color:#000000;
color:#FFFFFF;
float:center;
font-size:12px;
line-height:20px;
}
.pgnavi{
display:block;
height:30px;
font-size:12px;
line-height:20px;
float:center;
margin-right:3px;
}
-->
</style></head>
<table width="990" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><? include("modules/head-index.php"); ?></td>
</tr>
<tr>
<td align="center"><? include("modules/head-menu.php"); ?></td>
</tr>
<tr>
<td align="center"><? include("search_vien.php");?></td>
</tr>
<tr>
<td align="center">
</td>
</tr>
<tr>
<td height="62" align="center">
<table width="911" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="8%" height="29" bgcolor="#003333"><div align="center" class="style27 style31">ลำดับที่</div></td>
<td width="12%" bgcolor="#003333"><div align="center" class="style35">เลขที่หนังสือ </div></td>
<td width="12%" bgcolor="#003333"><div align="center"><span class="style35">เลขที่ E </span></div></td>
<td width="12%" bgcolor="#003333"><div align="center" class="style35">เลขที่ สพก. </div></td>
<td width="13%" bgcolor="#003333"><div align="center" class="style35">ลงวันที่</div></td>
<td width="29%" bgcolor="#003333"><div align="center" class="style35">รายละเอียด</div></td>
<td width="16%" bgcolor="#003333"><div align="center" class="style35">วันที่ลง website </div></td>
<td width="10%" bgcolor="#003333"><div align="center" class="style35">Download</div></td>
</tr>
<?
//$type=$_GET['type'];
/*$current_page = 1;
if(isset($_GET['page'])){
$current_page = $_GET['page'];
}
$row_per_page = 10;
$start_row = ($current_page-1)*$row_per_page;*/
include("connect_one.php");
//include("inc/paging.inc.php");
mysql_query("SET names utf8");
$type = $_GET['type'];
if($type=='quick'){
$sql = "SELECT * FROM bookv WHERE type = 'quick'";
}else if($type=='book-vien'){
$sql = "SELECT * FROM bookv WHERE type = 'book-vien' ";
}else if($type=='rid'){
$sql = "SELECT * FROM bookv WHERE type = 'rid' ";
}else{
"ไม่พบข้อมูล";
}
//echo $sql;
$dbq = mysql_query($sql);
$num_row = mysql_num_rows($dbq);
$Per_Page = 2; // 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_row<=$Per_Page)
{
$Num_Pages =1;
}
else if(($num_row % $Per_Page)==0)
{
$Num_Pages =($num_row/$Per_Page) ;
}
else
{
$Num_Pages =($num_row/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
//$sql = " ORDER BY bookid DESC LIMIT $Page_Start , $Per_Page";
$sql .=" ORDER BY bookid DESC LIMIT $Page_Start , $Per_Page";
$dbq = mysql_query($sql);
$a=1;
//$page=$_GET[Page];
$c+=3;
//echo $c;
while($row = mysql_fetch_array($dbq)){
$b++;
if($b%2==0){
$bg = "#FFFFFF";
}
else{
$bg = "#FFFFCC";
}
//$c++;
?>
<tr bgcolor="<?= $bg;?>">
<td height="47" align="center">
<span class="style47">
<?
if($_GET[Page]==""||$_GET[Page]==1){
echo $a;
}else{
echo $c;
}
//echo $c
?>
</span><span class="style46"></span></span></td>
<td align="center"><span class="style46"></span></span></td>
<td align="center"><span class="style47">
<?= $row['no_E']; ?>
</span></td>
<td align="center">
<span class="style47">
<?= $row['nobook']; ?>
</span><span class="style46"></span></span></td>
<td align="center">
<span class="style47">
<?= $row['date_book']; ?>
</span><span class="style46"></span></span></td>
<td align="left">
<span class="style47">
<?= $row['name']; ?>
</span><span class="style46"></span></span></td>
<td align="center"><span class="style47">
<?= $row["date"]; ?>
</span><span class="style46"></span></span></td>
<td><div align="center" class="style47"><a href="file_bookv/<?=$row["file"];?>" target="_blank"><img src="images/download.png" width="28" height="28" border="0" /></a>
</div></td>
</tr>
<?
$a++;
$c++;
//$e++;
}
?>
</table>
รวม
<?= $num_row;?>
รายการ :
<?=$Num_Pages;?>
หน้า :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&type=$type' class='mynavi'>Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[<a href='$_SERVER[SCRIPT_NAME]?Page=$i&type=$type' class='mynavi'>$i</a>]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&type=$type' class='mynavi'>Next</a> ";
}
mysql_close();
?>
</span></div></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
|
 |
 |
 |
 |
Date :
2012-03-05 17:30:56 |
By :
azanarak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2012-03-05 17:44:41 |
By :
azanarak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|