Welcome Guest, Not a member yet? Register   Sign In
How to sor the cart result on different key
#3

[eluser]1ONE[/eluser]
I had similar problem, so I made one more row in my products table called ORDER.

This is how I fill up the array:

Code:
$data = array();
foreach ($query->result() as $row):

$data[] = array('id' => $row->id, 'qty' => '1', 'price' => $row->price, 'name' => $row->name, 'order' => $row->order);
endforeach;


and let's sort the array:

Code:
function subval_sort($a,$subkey) {
    foreach($a as $k=>$v) {
        $b[$k] = strtolower($v[$subkey]);
    }
    asort($b);
    foreach($b as $key=>$val) {
        $c[] = $a[$key];
    }
    return $c;
}
$this->cart->insert(subval_sort($data, 'order'));

I hope this helps!


Messages In This Thread
How to sor the cart result on different key - by El Forum - 06-27-2010, 10:32 AM
How to sor the cart result on different key - by El Forum - 06-27-2010, 10:05 PM
How to sor the cart result on different key - by El Forum - 07-25-2011, 04:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB