มัน error แบบนี้ ต้องแก้ยังไงครับ select max(columnname) from tb where date_at(columname3,'%Y%m')='200901' group by date_at(columname2,'%d')
โค้ดครับ
Code (PHP)
<?
//select max(columnname) from tb where date_format(columname3,'%Y%m')='200901' group by date_format(columname2,'%d')
$strSQL =
"SELECT
`tb_province`.`name_prov`,
`tb_temperature`.`areas`,
`tb_areas`.`name_areas`,
MAX(temp_hight),
`tb_temperature`.`date_temp`
FROM
`tb_areas`
Inner Join `tb_province` ON `tb_province`.`id_prov` = `tb_areas`.`prov`
Inner Join `tb_temperature` ON `tb_areas`.`id_areas` = `tb_temperature`.`areas`
WHERE
MONTH(tb_temperature.date_temp)='$mm' AND YEAR(tb_temperature.date_temp)='$yy'
GROUP BY tb_temperature.date_temp
ORDER BY
`tb_temperature`.`date_temp` ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$name = array();
$temp = array();
$numrw=mysql_num_rows($objQuery);
if ($numrw == 0){
echo "ไม่พบข้อมูล";
}else{
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" align="center" valign="middle">
<img src='graph_lp_mount.php?<?echo $_SERVER['QUERY_STRING'];?>'>
</td>
</tr>
<tr>
<td width="50%" align="right" valign="middle"> </td>
<td width="50%" align="left" valign="top"> </td>
</tr>
<tr>
<td colspan="2" align="center" valign="top">
<table width="450" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#993300">
<tr>
<td class="head" width="40%" height="30" align="center" valign="middle" bgcolor="#CC6600">วันที่</td>
<td class="head" width="30%" height="30" align="center" valign="middle" bgcolor="#CC6600">พื้นที่</td>
<td class="head" width="30%" height="30" align="center" valign="middle" bgcolor="#CC6600">อุณหภูมิ (<sup></sup> ํC)</td>
</tr>
<?
$ii=0;
while($objResult = mysql_fetch_array($objQuery))
{
$d_temp= $objResult["date_temp"];
$tem_h= $objResult["MAX(temp_hight)"];
echo $tem_h;
$x1 = mysql_query("SELECT name_areas,temp_hight FROM tb_areas
Inner Join `tb_temperature` ON `tb_areas`.`id_areas` = `tb_temperature`.`areas`
WHERE temp_hight='$tem_h' && date_temp='$d_temp'");
//$area= $objResult["name_areas"];
echo $area= mysql_result($x1,0);
$prov= $objResult["name_prov"];
$name[] = $area;
$temp[] = $tem_h;
$date = sprintf('%04d-%02d-%02d',$y,$m,$d);
?>
<tr>
<td width="40%" height="30" align="center" valign="middle"><?echo thaidate($d_temp);?></td>
<td width="30%" height="30" align="left" valign="middle"><?echo ' '.$area;?></td>
<td width="30%" height="30" align="left" valign="middle"><?echo ' '.number_format($tem_h, 1);?></td>
</tr>
<?}}?>
Tag : - - - -
Date :
2010-05-20 09:56:20
By :
oasiis
View :
859
Reply :
5
Code (PHP)
echo "$objQuery";
ดูนะครับว่ามีค่าส่งมาป่าว
Date :
2010-05-20 11:01:41
By :
SOUL
ออกครับ
Date :
2010-05-20 11:46:56
By :
oasiis
ข้อมูลมันออกมาแบบนี้ครับ
Date :
2010-05-20 12:01:06
By :
oasiis
ตรงนี้ $area= mysql_result($x1,0);
ให้คุณลองใส่ชื่อ field ด้วย เพราะคิวรี่ $x1 คุณคิวรี่มา 2 field ใช่ปะ
$area= mysql_result($x1,0,"fieldname");
Date :
2010-05-20 15:22:39
By :
naskw
Load balance : Server 00