Tôi có một bảng như sau:Làm thế nào để Chọn Giá trị nhỏ nhất Từ Nhiều Cột với PHP
6xx 8xx 9xx 11xx 12xx
1 0.01 0.002 0.004 0.001 0.025
2 0.025 0.125 0.002 0.01 0.011
Tôi muốn tìm giá trị nhỏ nhất từ cột làm cho cột đó là màu xanh lá cây.
Ví dụ trong 1 giá trị nhỏ nhất là 0,001 vì vậy tôi muốn nó có màu xanh lá cây, cho 0,002 thứ hai là giá trị nhỏ nhất tôi muốn nó là màu xanh lá cây.
có thể bất kỳ một hướng dẫn cho tôi làm thế nào để làm cho điều này, nhờ
dưới đây là đoạn code làm thế nào tôi chọn nó từ cơ sở dữ liệu và hiển thị int trong một bảng
<?php
$dbHost = 'localhost'; // usually localhost
$dbUsername = 'xxxx';
$dbPassword = 'xxxx';
$dbDatabase = 'xxxx';
$db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");
$ColumnNames = mysql_query("SELECT column_name
FROM information_schema.COLUMNS
WHERE table_name = 'supplierprice'
AND column_name NOT IN ('supp_price_id',
'region',
'country',
'net_id',
'networkname',
'mcc',
'mnc',
'mnp')")
or die("mysql error");
$columnArray=array();
$i=0;
while($rows=mysql_fetch_array($ColumnNames))
{
$columnArray[]=$rows[0];
echo "<th style='width:67px;' class='. $columnArray[$i] .' >" . $columnArray[$i] . "
</th>";
$i++;
}
?>
foreach($columnArray as $value) {
//$columnArray[]=$rows1[0];
echo '<td style="width:67px;font-weight:'.$text.'" id="CPH_GridView1_xxx" width="0px;" class="'.$value.' '.$rows["net_id"].'"><p>'.$rows[$value].'</p></td>';
}
http://stackoverflow.com/questions/9570881/select-smallest-value-from-multiple-columns-with-php-mysql –