|  | 
	                
  
    | 
	 
        ข้อมูลไม่ยอมออกตามที่ผม echo ตัวแปรนั้นไว้อะครับ ไม่ทราบว่าผืดตรงไหนหรอครับ การแบ่งหน้า Page ออกนะครับ     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | DB ครับ id_pro
 name_pro
 data_pro
 price_pro
 pic_pro
 
 ผมยัง งง อะครับแต่การแบ่งหน้าออกนะครับ Page
 Code (PHP)
 
 <?php
$host = "localhost";
$user = "root";     
$passwd = "root"; 
$dbname = "admin";
	mysql_connect($host,$user,$passwd) or die("ติดต่อ Host ไม่ได้");
	mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");
	$sql = "select *from product ";
	$sqlquery=mysql_db_query($dbname,$sql); 
	$Num_Rows=0;
	while(mysql_fetch_array($sqlquery)){ $Num_Rows++; }
		$Per_Page = 6 ;
		$Page = $_GET["Page"];
    if(!$_GET["Page"])
    {   
		$Page = 1; 
	}
     
    $Prev_Page = $Page-1 ;
    $Next_Page = $Page+1 ;
    $Page_Start = (($Per_Page*$Page)-$Per_Page)+1;
   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;
    }
    $Page_End = $Per_Page * $Page;
    if($Page_End > $Num_Rows)
    {
        $Page_End = $Num_Rows;
    }     
 for($i=$Page_Start;$i<=$Page_End;$i++)
 {
mysql_fetch_array($sqlquery,$i);
$proId=mysql_result($sqlquery, "id_pro");
 $proName=mysql_result($sqlquery, "name_pro");
 $proDetail=mysql_result($sqlquery, "data_pro");
  //echo '>>=' .$sqlquery;
//exit;
 $proprice=mysql_result($sqlquery, "price_pro");
 $proimg=mysql_result($sqlquery, "pic_pro");
 echo '<div class="item">';
 echo '<a class="none_pdf" href="#"></a>';
 echo '<div class="item_pic">';
 echo '<form id="summit_cat" method="post" action="#.php?pid='.$proId.'">';
 echo '<img src="images/$proimg">';
 echo '<p>';
 echo '<strong>ชื่อเรื่อง  </strong>: $proName';
 echo '<br/>';
 echo '<strong>ประเภท</strong> : $proDetail';
 echo '<br/>';
 echo '<span class="price"><strong>ราคา</strong> : ฿$proprice</span>';
 echo '<br/>';
 echo '<br/>';
 echo '<input id="btn_cart" type="submit" value="หยิบใส่ตะกร้า"/>';
 echo '</p>';
 echo '</form>';
 echo '</div>';
 echo '</div>';
 }
  mysql_close();
?>
</div>
<br />
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?php
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> ";
}
?>
 
 
 Tag : PHP, MySQL
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2011-02-02 20:28:35 | By :
                          thegunmanolo | View :
                          839 | Reply :
                          3 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | น่าจะเป็นที่ใช้ fetch_array ผิดนะครับ ลองดูตามนี้ https://www.thaicreate.com/php/php-mysql-list-record.html
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-02-03 00:25:57 | By :
                            - - |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เอ่อโทษทีนะครับผมทำไม่ออกอีกแล้วครับ ทั่งรูปภาพ และข้อมูล 
 ผมสงสัยว่าเราสามารถทำแบบนี้ได้ไหม
 Code (PHP)
 
 $array=mysql_fetch_array($sqlquery,$i);
$id = $array['id_pro'];
$name_pro=$array['name_pro'];
$data_pro=$array['data_pro'];
$price_pro=$array['price_pro'];
$pic_pro=$array['pic_pro'];
 
 
 Code (PHP)
 
 <?
session_start();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="css/global.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/style.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
	<div id="header">
		<center>
		<h1 id="logo"><a href="#"><img alt="VDO" src="images/index_01.jpg" />
		</a></h1>
		</center></div>
	<ul id="nav">
		<li><a href="#">หน้าหลัก</a> </li>
		<li><a href="#">เกี่ยวกับเรา</a> </li>
		<li><a href="#">ติดต่อเรา</a> </li>
		<li><a href="#">วิธีสั่งซื้อ</a> </li>
	</ul>
	<div id="content" class="clearfix">
		<div id="col_main" class="clearfix">
			<div class="main_box clearfix col4">
				
<?php
$host = "localhost";
$user = "root";     
$passwd = "root"; 
$dbname = "admin";
	mysql_connect($host,$user,$passwd) or die("ติดต่อ Host ไม่ได้");
	mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");
	$sql = "select *from product ";
	$sqlquery=mysql_db_query($dbname,$sql); 
	$Num_Rows=0;
	while($objResult = mysql_fetch_array($sqlquery)){ $Num_Rows++; }
		$Per_Page = 6 ;
		$Page = $_GET["Page"];
    if(!$_GET["Page"])
    {   
		$Page = 1; 
	}
     
    $Prev_Page = $Page-1 ;
    $Next_Page = $Page+1 ;
    $Page_Start = (($Per_Page*$Page)-$Per_Page)+1;
   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;
    }
    $Page_End = $Per_Page * $Page;
    if($Page_End > $Num_Rows)
    {
        $Page_End = $Num_Rows;
    }     
 for($i=$Page_Start;$i<=$Page_End;$i++)
 {
$array=mysql_fetch_array($sqlquery,$i);
$id = $array['id_pro'];
$name_pro=$array['name_pro'];
$data_pro=$array['data_pro'];
$price_pro=$array['price_pro'];
$pic_pro=$array['pic_pro'];
  //echo '>>=' .$sqlquery;
//exit;
 echo '<div class="item">';
 echo '<a class="none_pdf" href="#"></a>';
 echo '<div class="item_pic">';
 echo '<form id="summit_cat" method="post" action="#.php?pid=$Id">';
 echo '<img src="../images/$pic_pro">';
 echo '<p>';
 echo '<strong>ชื่อเรื่อง  </strong>: $name_pro';
 echo '<br/>';
 echo '<strong>ประเภท</strong> : $data_pro';
 echo '<br/>';
 echo '<span class="price"><strong>ราคา</strong> : ฿$price_pro</span>';
 echo '<br/>';
 echo '<br/>';
 echo '<input id="btn_cart" type="submit" value="หยิบใส่ตะกร้า"/>';
 echo '</p>';
 echo '</form>';
 echo '</div>';
 echo '</div>';
 }
  mysql_close();
?>
</div>
<br />
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?php
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> ";
}
?>
			</div>
					<div id="col_right" class="clearfix">
			<div id="col_right_cate" class="clearfix">
				<h2>หมวดหมู่สินค้า</h2>
				<ul>
					<li><a href="#">Comedy</a> </li>
					<li><a href="#">Romantic</a> </li>
					<li><a href="#">Drama</a> </li>
					<li><a href="#">Action</a> </li>
					<li><a href="#">Animation</a> </li>
				</ul>
			</div>
			<div id="col_right_signin" class="clearfix">
				<h2>Login</h2>
				<center>
				<form name="form1" method="post" action="checkuser.php">
					<p><label>Username : <span class="star">*</span> </label>
					<br />
					<input type="text" name="logname">
					</p>
					<p><label>Password : <span class="star">*</span> </label>
					<br />
					<input type="password" name="pw">
					</p>
					<div class="bucket_button"><br/>
					<h3><a href="register.php">สมัครสมาขิกที่นี้</a></h3> <br/>
						<input type="submit" name="Submit" value="Login">
					</div>
					<? echo $code_error;?>
				</form>
				</center>
		</div>
	</div>
		</div>
</div>
</body>
</html>
 |  
              | 
 ประวัติการแก้ไข
 2011-02-03 22:31:01
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-02-03 21:52:47 | By :
                            thegunmanolo |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ได้แล้วครับขอบคุณมากครับ 
 ลองมั่วๆดูได้เฉยเลย ขอบคุณมากครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-02-04 01:04:51 | By :
                            thegunmanolo |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |