i have stored the records from database in a array. Now i want to sort the array based on the price index and than print the result according.
Can any one help me with this?
Code i tried ..
<?php
include('db.php');
$query = mysql_query("SELECT * FROM user");
$array = array();
while($row = mysql_fetch_assoc($query))
{
$array[] = $row;
$price[]=$row['price'];
}
echo "<pre>";
print_r($array);
Output..
Array
(
[0] => Array
(
[id] => 1
[name] => abc
[email] => abc@gmail.com
[contact] => 27488887
[price] => 12AED
)
[1] => Array
(
[id] => 2
[name] => siddharth
[email] => dgsfgsjkf@gmail.cm
[contact] => 7878787
[price] => 10AED
)
[2] => Array
(
[id] => 3
[name] => abc
[email] => def@gmail.com
[contact] => 4554545
[price] => 2AED
)
[3] => Array
(
[id] => 4
[name] => xyz
[email] => test@gmail.com
[contact] => 878778
[price] => 1AED
)
[4] => Array
(
[id] => 5
[name] => dandas
[email] => sdskagdsa
[contact] => 24221
[price] => 200AED
)
[5] => Array
(
[id] => 6
[name] => ass
[email] => asas
[contact] => 78787
[price] => 3AED
)
)
Now i want to sort the array obtained as output by price and then display the records..