dcuellar Posted January 29, 2008 Share Posted January 29, 2008 I'm trying to find a way to organize my shopping cart alphabetically. http://www.unifiedchamp.com/ucforum/cartplog.php?do=viewcategory&cartplogcatid=1 Here is a code within the php script that I noticed had ORDER in it. $cartplog_category_infos = $db->query_read("SELECT catid, title, products FROM " . TABLE_PREFIX . "cartplog_categories ORDER BY displayorder "); $cartplog['category_list'] = ''; while ($cartplog_category_info = $db->fetch_array($cartplog_category_infos)) { $cartplog['category_catid'] = intval($cartplog_category_info['catid']); $cartplog['category_products'] = intval($cartplog_category_info['products']); $cartplog['category_title'] = htmlspecialchars_uni($cartplog_category_info['title']); eval('$cartplog[\'category_list\'] .= "' . fetch_template('cartplog_category_list') . '";'); } Can this be done? Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/ Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 Not sure what you are asking for or what you like to do but here is a somthing maybe it might help. change ORDER BY displayorder TO ORDER BY title ASC to order it by title (a-z) OR ORDER BY title DESC to order it by title (z-a). If this dont help try and look up for MYSQL ORDER BY on google loool and try and make sense of that PS. oh n remember if you want to change it by product change "title" to "products" PS Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451782 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 Can I make it an option for the user to choose? Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451787 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 I just tried it and it did not work... I've included the full PHP script above if you don't mind taking a look at it. I basically want to organize by titles, not by ID numbers. For example, instead of 1, I want it to be sorted by F for Floyd Maywe... Any help with this would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451791 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 Ok. by putting the code above in that code I arranged something else...so obviously that is not where I need to place it. Let me keep on looking. Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451793 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 I imagine it has to be somewhere within this: $cartplog['category_list'] = ''; while ($cartplog_category_info = $db->fetch_array($cartplog_category_infos)) { $cartplog['category_catid'] = intval($cartplog_category_info['catid']); $cartplog['category_products'] = intval($cartplog_category_info['products']); $cartplog['category_title'] = htmlspecialchars_uni($cartplog_category_info['title']); eval('$cartplog[\'category_list\'] .= "' . fetch_template('cartplog_category_list') . '";'); } $db->free_result($cartplog_category_infos); But I don't see where. Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451800 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 I wasnt having a go at you mate just said that so i was clear find this file.on your server. cartplog.php and look for "ORDER BY catid" if you find that then change it to "ORDER BY title" hope it helps also on cartplog.php look for include() function coz they may have included other pages. Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451805 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 lol of course not. I appreciate your help...alot!! Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451808 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 There was nothing on the cartplog.php Could it be within a template? Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451812 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 I did a search within templates for that code and found nothing. I'm thinking, could it be arranged by date or order it was created? I don't know if that's possible or what code I'd be looking for. Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451815 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 find a function on your script function fetch_template($something) { CODES here SELECT blablabla FROM bla bla bla } find that and post a sample loool there should be a SELECT within the function Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451823 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 This whole time I thought I had my whole script up there...lol Here it is. there are several instances of SELECT. I'm just not sure which will affect which. Code deleted. Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451837 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 ok i think i found it not sure thought if not just check and let me know i have another look replace if ($_REQUEST['do'] == 'viewcategory') { $vbulletin->input->clean_array_gpc('r', array( 'cartplogcatid' => TYPE_UINT, )); $cartplog['categoryid'] = $vbulletin->GPC['cartplogcatid']; $cartplog_product_infos = $db->query_read("SELECT productid, thumb, title, price FROM " . TABLE_PREFIX . "cartplog_products WHERE catid = " . intval($cartplog['categoryid']) . " with if ($_REQUEST['do'] == 'viewcategory') { $vbulletin->input->clean_array_gpc('r', array( 'cartplogcatid' => TYPE_UINT, )); $cartplog['categoryid'] = $vbulletin->GPC['cartplogcatid']; $cartplog_product_infos = $db->query_read("SELECT productid, thumb, title, price FROM " . TABLE_PREFIX . "cartplog_products WHERE catid = " . intval($cartplog['categoryid']) . " ORDER BY title ASC Just add ORDER BY title ASC at the end that is the difference Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451844 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 it looks like its working now loool Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451847 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 Man!!! That worked!! Thanks a bunch!!! Is there any way to allow the option for the user to select whether they want to see it A-Z or Z-A? Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451849 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 hahaa ye there is but it has a lot more code you will have to put in one sec i might post somin for u Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451850 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 cool. Is there anything I can do for you? Do you like Boxing? Put a link of your website on our webpage? You name it. Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451852 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 my website is shit loool n that was a minor thing but ermm i can't do that optional thing because that is a very advanced and complicated code that it wud take me a while to understand it. and i would have done it if it was my web loool its coz i need to test it a few times to make sure it works try out different things loool Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451858 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 That's fine. Thanks for all your help though! Quote Link to comment https://forums.phpfreaks.com/topic/88288-sorting-in-php/#findComment-451865 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.