0
的下面的PHP數據庫查詢(從phpMyAdmin的)僅帶回一個值(第一個或最老的)轉換成amcharts:PHP數據庫查詢(phpMyAdmin的)僅帶回一個值(第一個)成amcharts
<?php
class custom_class2
{
var $charts; // reference to the calling object.
function customfunction2($content,$conf)
{
global $TSFE;
$TSFE->set_no_cache();
// do whatever you want here
// db connection
mysql_connect("hostname", "username", "password");
mysql_select_db("database name");
//db abfrage
$query = "
SELECT
YEAR(datetime) AS dy,
MONTH(datetime) -1 AS dm,
DAY(datetime) AS dd,
HOUR(datetime) AS th,
MINUTE(datetime) AS tm,
temp,
hum,
pressure
FROM stock1
ORDER BY datetime
";
// NEW: Variable definition
$zeilenzaehler = 1;
// output of the rows
$result = mysql_query($query) OR die("Error: $query <br>" . mysql_error());
while ($row = mysql_fetch_array($result))
{
// return
if ($zeilenzaehler != 1)
{
$content.= ",";
}
$content.= "{date: new Date(" . $row['dy'] . "," . $row['dm'] . "," . $row['dd'] . "," . $row['th'] . "," . $row ['tm'] . "),t:" . $row['temp'] . ",h:" . $row['hum'] . ",p:" . $row['pressure'] . "}";
return $content;
// Variable now on 2
$zeilenzaehler = 2;
}
}
}
?>
其他一切都看起來像它的工作正常。非常感謝您的幫助
感謝您的提示。您能否提供我需要做的確切更改? – Capamania 2015-02-08 16:11:42
我可以用mysqli發佈代碼,這樣你就可以看到我的意思了,我將只刪除你返回數據的行。 – taliezin 2015-02-08 16:21:32
那太棒了! – Capamania 2015-02-08 16:27:08