我在PHP開發中很新,我找不到解決我的問題的方法。
我必須清理我的Mysql數據庫中的一些數據。我有一個像SQL結果中的最大和最小PHP函數
-520;-510;0;-500;-530;-599;-499;-510;-490;-500;0;-450
在我的數據庫全時間段的date
列,我想從中提取出最小和最大價值,讓我只會有2個時間段離開。
我嘗試這樣做:
$sql = "SELECT date FROM records WHERE serial = 1";
$requete = mysql_query($sql,$cnx) or die(".mysql_error().");
while($result = mysql_fetch_array($requete))
{
$res = $result[date];
$min = min($res);
$max = max($res);
}
我明白,它不能正常工作,因爲MIN和MAX函數只與一個陣列工作,但我不知道如何變換分析我$result[date]
在一個新的數組。
PHP的'ext/mysql'('mysql_ *'系列)[已棄用](http://www.php.net/manual/en/faq.databases.php#faq .databases.mysql.deprecated)。請使用[其他](http://www.php.net/manual/en/mysqlinfo.api.choosing.php)。 – pilcrow