good day guys currently I'm making PHP(inventory management) for my items, in my system customers can buy items , I save customer ID and number of sold Items in one table (called it Sell table) in MySQL , now I want to show the best customer.(who bought the most items in my system) I wrote a code to find out how many items each customer bought ,but I don't know how I can show the best customer see this code :
$test= "SELECT c_id, SUM(n_sell) FROM sell GROUP BY c_id ";
$resut = mysql_query($test) or die(mysql_error());
while($t = mysql_fetch_array($resut)){
echo "Number of sold: ". $t['SUM(n_sell)'] ." to". $t['c_id'] .":id of customer";
echo "<br />";
}
It shows all of my customers with numbers of sold items to them, I need to show the specific customer who has the maximum number of sell item . for example, this is my result :
Number of sold: 11 to 2 :id of customer Number of sold: 103 to 3: id of customer
but the thing I want is just show :
Number of sold :103 to 3 :id of customer
I hope you guys can get me, thanks.