  | 
              
	              
	                
 
  
    |   | 
   
  
    
        
        ช่วยแก้โค้ด ASP การแบ่งหน้าแสดงข้อมูลในเพจ ให้ดูหน่อยครับ     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                นี้เป็นภาพที่ใช้ในตอนนี้ครับ 
 
  
 
นี้เป็นโค้ดที่ผมใช้อยู่ครับ 
 
Code (ASP) 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>หมายเลขประจำตัวผู้ประกอบการ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link href="font.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body,td,th {
	font-size: 14px;
}
.style2 {font-size: 12; }
.style3 {font-weight: bold}
.style5 {font-size: 12px; font-weight: bold; }
.style6 {color: #FFFFFF}
.style7 {font-size: 12; color: #FFFFFF; }
.style8 {color: #0077A5}
-->
</style>
<script language="JavaScript">
var year, month, date, hour, minute, second, today;
var dayString=new Array();
dayString[0]="อาทิตย์"; dayString[1]="จันทร์"; dayString[2]="อังคาร";
dayString[3]="พุธ"; dayString[4]="พฤหัสบดี"; dayString[5]="ศุกร์";
dayString[6]="เสาร์";
var monthString=new Array();
monthString[0]="มกราคม"; monthString[1]="กุมภาพันธ์"; monthString[2]="มีนาคม";
monthString[3]="เมษายน"; monthString[4]="พฤษภาคม"; monthString[5]="มิถุนายน";
monthString[6]="กรกฎาคม"; monthString[7]="สิงหาคม"; monthString[8]="กันยายน";
monthString[9]="ตุลาคม"; monthString[10]="พฤศจิกายน"; monthString[11]="ธันวาคม"; 
function now()
{
	dt = new Date();
	year = dt.getFullYear();
	month = dt.getMonth();
	day = dt.getDay(); 
	date = dt.getDate();
	
	today=" :  ดูข้อมูล ณ วัน " + dayString[day] + " ที่ " + date +" "+ monthString[month] + " พ.ศ. " + (year+543);
	document.getElementById('dPanel').innerHTML=today;
	setTimeout("now()",1000);
}
</script>
</head>
<%
         ConnString = "Driver={SQL Server};Server=localhost;Database=InfoTax;UID=sa;PWD=password;" 
         Set Conn = Server.CreateObject("ADODB.Connection")
         Conn.Open  ConnString
%>
<body  onLoad="now()">
<%
	strSQL = "SELECT * FROM ecomsum where TIN<>' '  AND PROVINCE_9 <> ' '  order by TIN ASC"
	Set objRec = Server.CreateObject("ADODB.Recordset")
	objRec.Open strSQL, Conn, 1,3
	If objRec.EOF Then
		Response.write (" Not found record.")	
	Else
	PageLen = 50
	PageNo = Request.QueryString("Page")
	if PageNo = "" Then PageNo = 1
	TotalRecord = objRec.RecordCount
	objRec.PageSize = PageLen
	TotalPage = objRec.PageCount
	objRec.AbsolutePage = PageNo
%>
<table width="95%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="750" height="200" class="font"><table width="968" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" class="font">
        <tr bordercolor="#FFFFFF" bgcolor="#FFFFFF" class="border">
          <td height="30" colspan="7" bordercolor="#FFFFFF"><div align="center" class="style8"><span class="style5">รายงานผู้ประกอบการที่มีเลขประจำตัวผู้เสียภาษี</span></div></td>
        <tr>
				<td> </td>
		</tr>
        <tr bordercolor="#FFFFFF" bgcolor="#0077A5" class="border"> 
          <td width="65" height="30" bordercolor="#FFFFFF" bgcolor="#0077A5"><div align="center" class="style2 style6">ลำดับที่</div></td>
          <td width="114"><div align="center" class="style6">หมายเลขประจำตัว</div></td>
          <td width="277"><div align="center" class="style6">ชื่อผู้ประกอบการ</div></td>
		  <td width="81"><div align="center" class="style6">หน่วยงาน</div></td>
          <td width="80"><div align="center" class="style6">ทีมกำกับ</div></td>
          <td width="239"><div align="center" class="style6">ประเภทกิจการ</div></td>
          <td width="54"><div align="center" class="style7">Website</div></td>
        </tr>
<%
	No=1
	Do While Not objRec.EOF and No <= PageLen
	numrec=numrec + 1
%>
<tr bordercolor="#FFFFFF" bgcolor="#E1F0FF">
          <td width="65" height="28"><div align="center"><span class="style2 style8"><%=numrec%></span></div></td>
          <td width="114" height="28"><div align="center"><span class="style2 style8"><%=objRec.Fields("tin").Value%></span></div></td>
          <td width="277" height="28"><span class="style2 style8"><%=objRec.Fields("name").Value%></span></td>
		  <td width="81" height="28"><div align="center"><span class="style2 style8"><%=objRec.Fields("pak_name").Value%></span></div></td>
		  <td width="80" height="28"><div align="center"><span class="style2 style8"><%=objRec.Fields("team").Value%></span></div></td>
          <td width="239" height="28"><span class="style2 style8"><%=objRec.Fields("descrip").Value%></span></td>
          <td width="54" height="28"><span class="style2 style8"><a href="<%="http://"&objRec.Fields("web1").Value%>" target="_blank"><%=objRec.Fields("web1").Value%></a></span></td>
        </tr>
<%
	No = No + 1
	objRec.MoveNext
	Loop
%>
</table>
<table width="965" border="0" align="center" cellpadding="0" cellspacing="0" class="font">
        <tr> 
<hr>
	ข้อมูลทั้งหมด : <%=TotalRecord%> 
	<br>
	
	<% IF Cint(PageNo) > 1 then %>
	<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=1"><< First</a> 
	<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=PageNo-1%>">< Back</a>
	<% End IF%>
	
	<% For intID = 1 To TotalPage%>
	<% if intID = Cint(PageNo) Then%>
	<b><%=intID%></b>
	<%Else%>
	[<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=intID%>"><%=intID%></a>]
	<%End IF%>
	<%Next%>
	
	<% IF Cint(PageNo) < TotalPage Then %>
	<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=PageNo+1%>">Next ></a> 
	<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=TotalPage%>">Last >></a>
	<% End IF%>
	
<%
End IF
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
<hr>
        </tr>
</table>	  
      <table width="375" border="0" align="center" cellpadding="0" cellspacing="0" class="font">
        <tr> 
                    <td width="85"> </td>
         			<td width="379"> </td>
        </tr>
        <tr> 
            <td><div align="right"><u>หมายเหตุ</u>  </div></td>
			<td><div align="left" id="dPanel">  </div></td>
        </tr>
        <tr> 
          <td width="85" height="16"> </td>
          <td width="379"> </td>
        </tr>
        <tr> 
          <td height="16" colspan="2"><div align=center>
                    <input type="button" name="ย้อนกลับ" value="ย้อนกลับ" onClick="history.back()"/>
          </div></td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
</body>
</html>
 
 
อยากให้ช่วยแก้โค้ดให้แสดงเหมือนในภาพนี้ให้ทีครับ 
 
 
 
 
  Tag : ASP               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2013-06-25 09:46:17 | 
                      By :
                          KT-Raiden | 
                      View :
                          2197 | 
                      Reply :
                          3 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ก่อนหน้านี้ก็ยังไม่ได้เหรอครับ แนะนำไปแล้วน่ะครับ ให้ใช้พวก IF Else ในการเปรียบเทียบค่าเพื่อแสดง Rank จำนวนหน้า ครับ ไม่ยาก                        
               
               | 
             
            
              
			  			  
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-06-26 15:03:40 | 
                        By :
                            mr.win | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 คือว่าจะใส่ IF Else อย่างไงครับผมยังนึกไม่ออกเลยครับ มีตัวอย่างให้ดูไหมครับ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-06-28 14:10:21 | 
                        By :
                            KT-Raiden | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (ASP) 
<%
pageLen =10 'กำหนดจำนวนแต่ละหน้าที่ต้องการแสดงกี่ Reccord
pageNo = request.QueryString("page")
if pageNo="" then pageNo = 1
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT * FROM pm where tblAuthor ='" & Session("AfUsername") & "' and tblCat=3 order by tblDate_save DESC"
rs.Open sql, conn,1,3
If Rs.EOF Then
%>
ไม่มีข้อมูล
<%
Else
Mailrecord = Rs.recordcount
Rs.pageSize = pageLen
totalPage = Rs.PageCount
Rs.absolutePage = pageNo
%>
ใส่ข้อมูล อาจจะเป็นส่วนหัวของตาราง
<%
recNo=1
Do While Not RS.EOF and recNo <= pageLen
%>
ใส่ข้อมูลที่ต้องการแสดงตรงนี้
<%
recNo=recNo+1
If pageNo="1" Then
ResultsCount = recNo
Else
ResultsCount = (pageNo&"0")+recNo-10
End if
Scount = (pageNo&"0")-PageLen+1
Mcount = ResultsCount-1
RS.MoveNext
Loop
rs.close
conn.close
%>
อันนี้ปุ่มกด Previous page กับ Nextpage
<%
if cint(pageno) > 1 then %>
<input type="button" class="form-site2" value="Previous" onClick="window.location='pm.asp?mailbox=<%=mailbox%>&page=<%=pageNo-1%>'">
 
<% end if
if cint(pageno) < totalPage then %>
<input type="button" class="form-site2" value="Next" onClick="window.location='pm.asp?mailbox=<%=mailbox%>&page=<%=pageNo+1%>'">
<%
end if
%>
<%
end if
%>
<!--ช่วงนี้แสดงสถานะ ว่าคุณอยู่หน้าไหนและ จากรายการไหน ถึง รายการไหน-->
หน้าที่ [<%=pageNo%> จากทั้งหมด <%=totalPage%>หน้า] ♥ รายการที่ [<%=SCount%> - <%=MCount%>] จากทั้งหมด <%=Mailrecord%> รายการ
<!-- อันนี้คือลิงก์ไปหน้าต่างๆ -->
<%
if cint(pageno) > 1 then %>
<a href="pm.asp?mailbox=<%=mailbox%>&page=<%=pageNo-1%>"><b>«Prev</b></a><%end if%><%for idx = 1 to totalPage
%>
<a href="pm.asp?mailbox=<%=mailbox%>&page=<%=idx%>" class="searchlink"><% if idx=cint(pageno) then%></a><b style="background-color: indigo; border: 1px solid #0C5444; padding-left: 2px; padding-right: 2px; padding-bottom: 1px;" class="lg-text"><font color=#ffffff><%=idx%></font></b><%else %><%=idx%><%end if%> 
<%
next%><% if cint(pageno) < totalPage then %>
<a href="pm.asp?mailbox=<%=mailbox%>&page=<%=pageNo+1%>"><b>Next</b>»</a>
<%
end if
%>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-06-28 14:23:38 | 
                        By :
                            next | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |