|
|
Code (PHP)
$sql = "select ID from ID order by No Asc";
$query = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($query);
$strFileName = "fromdb.txt";
$objFopen = fopen($strFileName, 'w');
If ($num >0) {
for($i=0;$i<$num;$i++)
{
$row = mysql_fetch_array($query);
$arr[] = $row['ID'];
echo $arr[$i];
?>
<br>
<?
$sql1 = "select Date, $arr[$i] from Active order by Date Asc";
$query1 = mysql_query($sql1) or die(mysql_error());
$num1 = mysql_num_rows($query1);
echo "$", $arr[$i], "= [";
fputs($objFopen, "$");
fputs($objFopen, $arr[$i]);
fputs($objFopen, "= [");
for($b=0;$b<$num1;$b++)
{
$row1 = mysql_fetch_array($query1);
$arr1[] = $row1[$arr[$i]];
$arr2[] = $row1['Date'];
$arr3="['";
$arr3.= $arr2[$b];
$arr3.= "',";
$arr3.= $arr1[$b];
If ($b<$num1-1){
$arr3.="],";
}
If ($b>=$num1-1){
$arr3.="]];";
}
//echo "[",$arr2[$b], ",", $arr1[$b], "]";
echo $arr3;
fputs($objFopen, $arr3);
?>
<?
//echo $arr3;
}
// fputs($objFopen, "]");
?>
<br>
<?
fputs($objFopen, "\r\n");
}
}
fclose($objFopen);
ค่าที่ได้ เป็นแบบนี้ค่ะ ค่่าตรงสีแดง เปลี่ยน แต่สีม่วงไม่เปลี่ยน ค่าเหมือนเดิมตลอดเลยค่ะ โดยค่า ตรงสีแดงได้จาก $arr[$i], ส่วนสีม่วงได้จาก $arr3 ค่ะ ต้องวน loop ยังไงถึงจะได้ค่าที่ถูกต้องหล่ะคะเนี่ย
$MSA01= [['2011-06-09 00:00:00',0],['2011-06-09 00:10:00',0],['2011-06-09 00:20:00',0],['2011-06-09 00:30:00',0],['2011-06-09 00:40:00',0],['2011-06-09 00:50:00',0],['2011-06-09 01:00:00',0],['2011-06-09 01:10:00',0],['2011-06-09 01:20:00',0],['2011-06-09 01:30:00',0],['2011-06-09 01:40:00',0],['2011-06-09 01:50:00',0],['2011-06-09 02:00:00',0],['2011-06-09 02:10:00',0],['2011-06-09 02:20:00',0],['2011-06-09 02:30:00',0],['2011-06-09 02:40:00',0],['2011-06-09 02:50:00',0],['2011-06-09 03:00:00',0],['2011-06-09 03:10:00',0],['2011-06-09 03:20:00',1],['2011-06-09 03:30:00',0]];
$MSA02= [['2011-06-09 00:00:00',0],['2011-06-09 00:10:00',0],['2011-06-09 00:20:00',0],['2011-06-09 00:30:00',0],['2011-06-09 00:40:00',0],['2011-06-09 00:50:00',0],['2011-06-09 01:00:00',0],['2011-06-09 01:10:00',0],['2011-06-09 01:20:00',0],['2011-06-09 01:30:00',0],['2011-06-09 01:40:00',0],['2011-06-09 01:50:00',0],['2011-06-09 02:00:00',0],['2011-06-09 02:10:00',0],['2011-06-09 02:20:00',0],['2011-06-09 02:30:00',0],['2011-06-09 02:40:00',0],['2011-06-09 02:50:00',0],['2011-06-09 03:00:00',0],['2011-06-09 03:10:00',0],['2011-06-09 03:20:00',1],['2011-06-09 03:30:00',0]];
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2011-06-24 15:32:08
|
|
|
|
|
Date :
2011-06-24 14:57:17 |
By :
Mminnano |
View :
1465 |
Reply :
4 |
|
|
|
|
|
|
|
|
|