mysql數據庫的最高值,這是MySQL表如何顯示在php
---------------------------------------------
id | date | name | amount
---------------------------------------------
1 | 2013-01-31 | abcd | 200.000
2 | 2013-02-28 | apple | 95.000
3 | 2013-03-31 | bannna | 30.000
4 | 2013-04-30 | computer | 5.000
5 | 2013-05-31 | mobile | 500.000
6 | 2013-06-30 | mouse | 2.000
7 | 2013-07-31 | led tv | 25000.000
---------------------------------------------
如何找到這個表格
我想造成這樣的PHP頁面 量最高值1的最高值量
Date | Name | Amount
2013-07-31 | LED TV | 25000.000
2013-05-31 | Mobile | 500.000
2013-01-31 | Abcd | 200.000
2013-02-28 | Apple | 95.000
我怎麼能做到這一點請大家幫我解決這個問題 感謝
我使用此代碼,但它沒有顯示我的結果類型。
<?php
$username = "root";
$password = "";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
//select a database to work with
$selected = mysql_select_db("car",$dbhandle)
or die("Could not select examples");
//execute the SQL query and return records
$result = mysql_query("SELECT MAX(amount) AS amount FROM table5");
//fetch tha data from the database
while ($row = mysql_fetch_array($result)) {
echo "Date:".$row{'date'}." Name:".$row{'name'}."Amount: ". //display the results
$row{'amount'}."<br>";
}
//close the connection
mysql_close($dbhandle);
?>
是一個int或varchar的數量? – zzlalani
你可以根據你的需要改變你的查詢SELECT MAX(amount)AS amount FROM table5 order by amount desc或asc。 – SeeSharp
amount is varchar – user2468472