我有一个PHP页面,用于检索$_SESSION['products']
会话中的数组。该会话中的每个阵列都是用户添加到他们的购物车中的产品。通过catalogue.php
页面。目前我的会话有11个阵列,这意味着我已经将11个产品添加到购物车中。我现在正尝试在view_cart.php
页面上显示数组,并将它们分成10个。基本上我希望页面显示前十个数组,然后在view_cart.php?Page=2
上显示第十一个数组。现在,代码一次显示页面上的所有11个数组,并在每个数组之前显示三条错误消息。我已经发布了以下错误。
警告:mssql_query()[function.mssql-query]:message:不正确 语法附近' OFFSET'。 (严重程度15)in 第63行的D:\ Hosting \ 4502990 \ html \ partscatalogue \ view_cart4.php
警告:mssql_query()[function.mssql-query]:message:使用无效 FETCH语句中的NEXT选项。 (严重程度15)in 第63行的D:\ Hosting \ 4502990 \ html \ partscatalogue \ view_cart4.php
警告:mssql_query()[function.mssql-query]:查询失败 第63行的D:\ Hosting \ 4502990 \ html \ partscatalogue \ view_cart4.php
警告:mssql_fetch_object():提供的参数不是有效的MS SQL结果资源 第64行的D:\ Hosting \ 4502990 \ html \ partscatalogue \ view_cart4.php
以下是view_cart.php
页面的完整PHP页面代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
session_start();
include_once("config.php");
$cart_items = 0;
foreach ($_SESSION['products'] as $cart_itm)
{
$cart_items ++;
}
$Number_of_Arrays = $cart_items;
echo "Number of Arrays: ".$Number_of_Arrays."";
$Per_Page = 10; // 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($Number_of_Arrays<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Number_of_Arrays % $Per_Page)==0)
{
$Num_Pages =($Number_of_Arrays/$Per_Page) ;
}
else
{
$Num_Pages =($Number_of_Arrays/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$Page_End = $Per_Page * $Page;
IF ($Page_End > $Number_of_Arrays)
{
$Page_End = $Number_of_Arrays;
}
?>
<?php
if(isset($_SESSION["products"]))
{
$total = 0;
echo '<form method="post" action="PAYMENT-GATEWAY">';
echo '<ul>';
$cart_items = 0;
$i = 0;
foreach ($_SESSION['products'] as $cart_itm)
{
$product_code = $cart_itm["code"];
$queryy = "SELECT TOP 1 product_name,product_desc, price FROM products ORDER BY id OFFSET (($Page - 1) * $Per_Page) FETCH NEXT $Per_Page ONLY";
$results = mssql_query($queryy, $mysqli);
$obj = mssql_fetch_object($results);
echo '<li class="cart-itm">';
echo '<span class="remove-itm"><a href="cart_update.php?removep='.$cart_itm["code"].'&return_url='.$current_url.'">×</a></span>';
echo '<div class="p-price">'.$currency.$obj->price.'</div>';
echo '<div class="product-info">';
echo '<h3>'.$obj->product_name.' (Code :'.$product_code.')</h3> ';
echo '<div class="p-qty">Qty : '.$cart_itm["qty"].'</div>';
echo '<div>'.$obj->product_desc.'</div>';
echo '</div>';
echo '</li>';
$subtotal = ($cart_itm["price"]*$cart_itm["qty"]);
$total = ($total + $subtotal);
echo '<input type="hidden" name="item_name['.$cart_items.']" value="'.$obj->product_name.'" />';
echo '<input type="hidden" name="item_code['.$cart_items.']" value="'.$product_code.'" />';
echo '<input type="hidden" name="item_desc['.$cart_items.']" value="'.$obj->product_desc.'" />';
echo '<input type="hidden" name="item_qty['.$cart_items.']" value="'.$cart_itm["qty"].'" />';
$cart_items ++;
}
echo '</ul>';
echo '<span class="check-out-txt">';
echo '<strong>Total : '.$currency.$total.'</strong> ';
echo '</span>';
echo '</form>';
echo '<a href="checkout.php">Checkout</a>';
}
?>
</body>
</html>
以下是我的config.php
页面的完整代码:
<?php
$mysqli = mssql_connect('dag','gfa','dca');
$objConnectee = mssql_select_db('gba',$mysqli );
?>
感谢您的帮助。感谢所有帮助。