  | 
              
	              
	                
  
    
	 
        รบกวนด้วย คับ ต่อจากหัวข้อที่แล้ว คับ รูป ขึ้นแล้ว พอดีผมทำแบ่งหน้าได้แล้ว แล้วอยาก ให้มันโชว์ ออกมา หน้าละ 20 รูป โดย โชว์ 5 รูป แล้วตัดขึ้นบรรทัดใหม่ ต้องทำไงคับ     | 
   
  
    |   | 
   
 
 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
<table border="1" width="500">
	<tr>
    	<? 
		for($i=1;$i<=50;$i++){
			echo '<td>'.$i.'</td>';
			if($i%10==0){
				echo '</tr><tr>';
			}
		}
		?>
</table>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-03-17 01:17:06 | 
                        By :
                            Krungsri | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                   
 
PHP MySQL Multiple Column and Paging/Pagination 
                        
               
               | 
             
            
              
			  			  
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-03-17 06:56:27 | 
                        By :
                            mr.win | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 <!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" /> 
<title>Untitled Document</title> 
</head> 
 
<body> 
<? 
$objConnect = mysql_connect("localhost","root","12345") or die(mysql_error()); 
$objDB = mysql_select_db("db_test"); 
$strSQL = "SELECT * FROM front"; 
$objQuery = mysql_query($strSQL); 
$Num_Rows = mysql_num_rows($objQuery); 
$Per_Page = 4;   // 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_Rows<=$Per_Page) 
{ 
$Num_Pages =1; 
} 
else if(($Num_Rows % $Per_Page)==0) 
{ 
$Num_Pages =($Num_Rows/$Per_Page) ;} 
else 
{ 
$Num_Pages =($Num_Rows/$Per_Page)+1; 
$Num_Pages = (int)$Num_Pages; 
} 
$strSQL .=" order  by image_id DESC $Page_Start , $Per_Page"; 
$objQuery  = mysql_query($strSQL); 
echo"<table border=\"0\"  cellspacing=\"1\" cellpadding=\"1\"><tr>"; 
$intRows = 0; 
while($objResult = mysql_fetch_array($objQuery)) 
{ 
echo "<td>"; 
$intRows++; 
?> 
<center> 
<img src="index_images/<?=$objResult["image_name"];?>"><br> 
<?=$objResult["image_name"];?> 
<br> 
</center> 
<? 
echo"</td>"; 
if(($intRows)%2==0) 
{ 
echo"</tr>"; 
} 
} 
echo"</tr></table>"; 
?> 
<br> 
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : 
<? 
if($Prev_Page) 
{ 
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> "; 
} 
for($i=1; $i<=$Num_Pages; $i++){ 
if($i != $Page) 
{ 
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"; 
} 
else 
{ 
echo "<b> $i </b>"; 
} 
} 
if($Page!=$Num_Pages) 
{ 
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> "; 
} 
?> 
</body> 
</html> 
<? 
mysql_close($objConnect); 
?> 
 
เออเร่อ Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\test\untitled.php on line 40 
ผมเช็ค connect db ก็ถูกแล้วคับ เลย งง เลย รบกวนด้วยคับ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-03-17 11:52:47 | 
                        By :
                            HunNuJI | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
<!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" />
<title>Untitled Document</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","12345") or die(mysql_error());
$objDB = mysql_select_db("db_test");
$strSQL = "SELECT * FROM front";
$objQuery = mysql_query($strSQL);
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 4; // 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_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by image_id DESC LIMIT $Page_Start , $Per_Page"; // กำหนด จำนวนต้องใส่ LIMIT ด้วยครับ ไม่งั้น Systax จะผิดพลาด
$objQuery = mysql_query($strSQL);
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
echo "<td>";
$intRows++;
?>
<center>
<img src="index_images/<?=$objResult["image_name"];?>"><br>
<?=$objResult["image_name"];?>
<br>
</center>
<?
echo"</td>";
if(($intRows)%2==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
?>
<br>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
?>
</body>
</html>
<?
mysql_close($objConnect);
?>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-03-17 11:58:30 | 
                        By :
                            Ex-[S]i[L]e[N]t | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 oh !!! ได้แล้วคับ  ขอบคุณ ทุกๆ คน และคุณ  Ex-[S]i[L]e[N]t มากๆ คับ  สำหรับคามรู้ต่างๆ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-03-17 12:10:11 | 
                        By :
                            HunNuJI | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |