wild_dog Posted May 29, 2006 Share Posted May 29, 2006 Hi there,Im trying to write a function that does the following:I have a form which has items from a mysql database. At the moment when you clickon an item from the page and add it to a cart the items are being displayed in random order.I want the items to be displayed in the order they are clicked onAny ideas??Cheers Quote Link to comment Share on other sites More sharing options...
samshel Posted May 29, 2006 Share Posted May 29, 2006 please paste the query which you are using to get items in the cart, if the items are in session then please paste the code which you use to display cart items.. Quote Link to comment Share on other sites More sharing options...
wild_dog Posted May 29, 2006 Author Share Posted May 29, 2006 [!--quoteo(post=378007:date=May 29 2006, 02:24 AM:name=wild_dog)--][div class=\'quotetop\']QUOTE(wild_dog @ May 29 2006, 02:24 AM) [snapback]378007[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi there,Im trying to write a function that does the following:I have a form which has items from a mysql database. At the moment when you clickon an item from the page and add it to a cart the items are being displayed in random order.I want the items to be displayed in the order they are clicked onAny ideas??Cheers[/quote]Have a look below:I was thinking of somehow assigning a key/id to each item as they are entered and keep a count. Then you fecth the items from the DB as they are added and just display them in the order the keys were assigned (but im thinking another table or two might need to be created for this?? )Also if the user was then to come back and add more items the function would look for the max count as they were entered and add to the end of the list. Got an idea??==========================================================<?php//WA eCart Includerequire_once("../WA_eCart/blade_cart_PHP.php");session_start();?><?php require_once('../Connections/blade.php'); ?><?php$blade_cart->GetContent();?><?php$maxRows_Recordset1 = 5;$pageNum_Recordset1 = 0;if (isset($_GET['pageNum_Recordset1'])) {$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];}$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;$colname_Recordset1 = "-1";if (isset($_POST['size'])) {$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_POST['size'] : addslashes($_POST['size']);}mysql_select_db($database_blade, $blade);$query_Recordset1 = sprintf("SELECT ProdID, ProdName, ProdPrice FROM products WHERE ProdID = %s", $colname_Recordset1);$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);$Recordset1 = mysql_query($query_limit_Recordset1, $blade) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);if (isset($_GET['totalRows_Recordset1'])) {$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];} else {$all_Recordset1 = mysql_query($query_Recordset1);$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);}$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;?><?php// WA eCart AddToCartif (isset($_POST["blade_cart_1_ATC"]) || isset($_POST["blade_cart_1_ATC_x"])) {$ATC_itemID = $_POST["blade_cart_1_ID_Add"];$ATC_AddIfIn = 2;$ATC_RedirectAfter = "../shopping_cart/cart.php";$ATC_RedirectIfIn = "";$ATC_itemName = "".$row_Recordset1['ProdName'] ."";// column binding$ATC_itemDescription = "testdesc";// column binding$ATC_itemWeight = floatval("0");// column binding$ATC_itemQuantity = "".$_POST["blade_cart_1_Quantity_Add"] ."";// column binding$ATC_itemPrice = floatval("".$row_Recordset1['ProdPrice'] ."");// column binding$ATC_itemQuantity = floatval($ATC_itemQuantity);if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {$blade_cart->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice);if ($ATC_RedirectAfter != "" && $blade_cart->redirStr == "") {$blade_cart->redirStr = $ATC_RedirectAfter;}if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];}else {$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];}}}?><?php============================================================= Quote Link to comment Share on other sites More sharing options...
samshel Posted May 29, 2006 Share Posted May 29, 2006 You can add a field in the cart items table (add_time) and sort the query on this field$ATC_itemTime = now();hth... Quote Link to comment Share on other sites More sharing options...
Barand Posted May 29, 2006 Share Posted May 29, 2006 You asked this question yesterday and you were advised to record the time but chose to ignore it.[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=94438&hl=\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...topic=94438&hl=[/a]Now you ask it again and get the same advice from another source.1. Don't double post.2. If you are just going to reject any advice offered, why post at all? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.