shedcade Posted February 28, 2011 Share Posted February 28, 2011 Hi all i love being able to view the customers who have ordered the most (and seeing their rank in the left column). Can anyone help me attach this rank to the customer and display it alongside their details in admin/customers.php? The code is from stats_customers, can it be modified and re-used, all help greatly appreciated! $customers_query_raw = "select c.customers_firstname, c.customers_lastname, sum(op.products_quantity * op.final_price) as ordersum from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS . " o where c.customers_id = o.customers_id and o.orders_id = op.orders_id group by c.customers_firstname, c.customers_lastname order by ordersum DESC"; $customers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $customers_query_raw, $customers_query_numrows); // fix counted customers $customers_query_numrows = tep_db_query("select customers_id from " . TABLE_ORDERS . " group by customers_id"); $customers_query_numrows = tep_db_num_rows($customers_query_numrows); $rows = 0; $customers_query = tep_db_query($customers_query_raw); while ($customers = tep_db_fetch_array($customers_query)) { $rows++; if (strlen($rows) < 2) { $rows = '0' . $rows; } Link to comment Share on other sites More sharing options...
burt Posted February 28, 2011 Share Posted February 28, 2011 Arrange the output using <ol> and <li> - in other words, an ordered list. Link to comment Share on other sites More sharing options...
shedcade Posted February 28, 2011 Author Share Posted February 28, 2011 Sorry, didnt make myself clear, just wanted the rank for one customer on their page, so if they are my 100th best customer, they have 'rank 100' alongside their name in admin/customers.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.