|
 |
|
รบกวลเรื่อง การแสดงสินค้า แบบแยกเป็นหน้าๆ แสดงได้แล้ว แต่ติดที่แยกหน้าเวลาคลิกแล้วไม่ไป |
|
 |
|
|
 |
 |
|
ตอนนี้ทำระบบสินค้า แบบ แต่จะให้แยกหน้าสินค้า แยกไม่ได้ งง code คิดว่าถูกแล้ว แต่มันก็ไม่ได้ ช่วยด้วยจ้า
สงค่า get มาจากการกด link รูปแบบการส่งคือ product.php?id_select=$record[specie_type] //ส่งชินดสินค้ามา
product.php
Code (PHP)
<script type="text/javascript" src="ajax/cart.js"></script>
<body>
<?
include "connect.php";
$get=$_GET["id_select"]; // รับมาในรูปแบบ get
$strPage=$_POST['page'];
$strSQL = "SELECT * FROM product_rmutl ";
if ($get!="") {
$strSQL.= "WHERE type_pro = '$get' ";
}
$objQuery = @mysql_query($strSQL) or die(mysql_error());
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page=12;
$Page=$strPage;
if(!$strPage) {
$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 no_pro ASC LIMIT $Page_Start , $Per_Page";
$objQuery = @mysql_query($strSQL) or die(mysql_error());
echo"<form id=frmPro><table border=0 cellspacing=1 cellpadding=1 width=100%><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
echo "<td align=center width=200>";
?>
<img src="image/product/<?=$objResult["pic_pro"];//รูป?>" alt="<?=$objResult["detail_pro"];//รายละเอียด?>" width="113" height="140" border="0">
<center>
<?=$objResult["name_pro"];//ชื่อสินค้า?>
<br>
ราคา <span class="price"><?=number_format($objResult["price_pro"],2);?></span> บาท
<br>
จำนวน <input type="text" id="txt<?=$intRows;?>" value="" size="3"><br>
<input type="button" value="หยิบใส่ตะกร้า" onClick="return check_num(frmPro.txt<?=$intRows;?>.value, <?=$intRows;?>,<?=$objResult["no_pro"];?>, 'ADD')">
</center>
<?
echo"</td>";
if(($intRows)%4==0) {
echo"</tr>";
} else {
echo "<td>";
}
}
echo"</tr></table></form><br>";
?>
<br>
<?
if($Prev_Page) {
echo " <a href=\"JavaScript:doListProd('$get', '$Prev_Page')\"><< Back</a> ";
}
for($i=1;$i<=$Num_Pages; $i++){
if($i!=$Page) {
echo "[ <a href=\"JavaScript:doListProd('$get', '$i')\">$i</a> ]";
} else {
if ($Num_Rows!=0) {
echo "<b> หน้า $i </b>";
} else {
echo "ไม่มีรายการสินค้าในหมวดนี้";
}
}
}
if($Page!=$Num_Pages) {
echo " <a href=\"JavaScript:doListProd('$get', '$Next_Page')\">Next >></a> ";
}
?>
</body>
</html>
cart.js
Code (PHP)
function newXmlHttp(){
var xmlhttp = false;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlhttp = false;
}
}
if(!xmlhttp && document.createElement){
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function doListProd(ID, Page) {
var url = 'product.php';
var pmeters = "id_select=" + ID +
"&page=" + Page;
xmlhttp = newXmlHttp();
xmlhttp.open('POST',url,true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", pmeters.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(pmeters);
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState == 3) // Loading Request
{
document.getElementById("listprod").innerHTML = "Now is Loading...";
}
if(xmlhttp.readyState == 4) // Return Request
{
document.getElementById("listprod").innerHTML = xmlhttp.responseText;
}
}
}
ผลที่ออกมา แสดงสินค้า แบบ 3 โร 4 คอลั่ม แต่พอคลิกไป หน้า 2 มันนิ่งเลย รบกวลด้วย ^^" งง มาทั้งวันแล้ว
Tag : PHP, JavaScript, Ajax, jQuery

|
|
 |
 |
 |
 |
Date :
2013-09-09 15:21:42 |
By :
byeasy |
View :
797 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำไมไม่ส่งค่า $_POST['page'] ไปแบบ GET ดูครับ?
|
 |
 |
 |
 |
Date :
2013-09-09 15:26:17 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เหมือนเดิม กด แล้วไปหน้าถัดไปไม่ได้เลย
|
 |
 |
 |
 |
Date :
2013-09-09 16:03:29 |
By :
byeasy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|