|
 |
|
ช่วยดูให้ทีครับตัวแปร php เอามาใช้ใน javascript แล้ว error ตัวนึงไม่ error ตัวนึง |
|
 |
|
|
 |
 |
|
คือผมคิวรี่ข้อมูลเสร็จเอาผลมาประมวลผลได้เป็นตัวแปร 2ตัวคือ $bankok กับ $bankokcolor จะเอาผลไปใช้ในจาวาสคิบ แต่มันมีปัญหาอยู่ว่า ตัวแปร $bankok ไม่error แต่ตัวแปร $bankokcolor error คือถ้าเอาตัวแปร $bankokcolor ออกก็จะทำงานปกติ ไม่ทราบว่าเป็นเพราะอะไรแล้วแก้ไขยังไงครับ
[head]ช่วยดูให้ทีครับhead]
if(isset($_POST['dis'])){
$dis=$_POST['dis'];
$red=$_POST['red'];
$orange=$_POST['orange'];
$yellow=$_POST['yellow'];
$stdate=$_POST['stdate'];
$ladate=$_POST['ladate'];
$strSQL = "
SELECT *
FROM inform,address
WHERE inform.id_address = address.id_address
AND address.province = 'กรุงเทพมหานคร'
";
if($dis != "")
{
$strSQL .= "AND inform.disease = '".$dis."'";
}
if($stdate != "")
{
$d_st = substr($stdate,3,2);
$m_st = substr($stdate,0,2);
$y_st = substr($stdate,6,4);
$strSQL .= " AND inform.found_date >= '".$d_st."'
AND inform.found_month >= '".$m_st."'
AND inform.found_year >= '".$y_st."'
";
}
if($ladate != "")
{
$d_la = substr($ladate,3,2);
$m_la = substr($ladate,0,2);
$y_la = substr($ladate,6,4);
$strSQL .= " AND inform.found_date <= '".$d_la."'
AND inform.found_month <= '".$m_la."'
AND inform.found_year <= '".$y_la."'
";
}
$objQuery = mysql_query($strSQL);
$bankok = mysql_num_rows($objQuery);
if($bankok>=$red){
$bankokcolor="#ff0000";
}
else{
if($bankok>=$orange){
$bankokcolor="#ff9c00";
}
else{
if($bankok>=$yellow){
$bankokcolor="#f6ff00";
}
else{
$bankokcolor="#00ff36";
}
}
}
?>
<script type="text/javascript">
var bankok = <?=$bankok;?>;
//var color_1 = <?=$bankokcolor;?>; //ติดที่ตัวนี้ครับ
alert(bankok);
function map() {
map = new GMap(document.getElementById("div_map"));
map.addControl(new GLargeMapControl3D());
map.setCenter(new GLatLng(13.80608, 100.57983), 6);
var polygon = new GPolygon([
new GLatLng(12.656418,100.991821), //1
new GLatLng(12.663117,100.991821),//2
new GLatLng(12.91623,101.083832), //3
new GLatLng(13.087504,101.177216), //4
new GLatLng(13.083491,101.561737), //5
new GLatLng(13.167748,101.645508), //6
new GLatLng(13.143678,101.6922), //7
new GLatLng(12.861343,101.824036), //8
new GLatLng(12.692593,101.778717), //9
new GLatLng(12.594774,101.417542), //9
new GLatLng(12.656418,100.991821) //1
], "#f33f00", 2, 1, "#ff0000", 0.2);
map.addOverlay(polygon);
}
</script>
<body onload="map()">
<div id="div_map" style="width: 680px; height: 800px"></div>
</body>
<?
}
?>
Tag : PHP, MySQL, JavaScript

|
|
 |
 |
 |
 |
Date :
2010-11-25 23:33:03 |
By :
airzio |
View :
1157 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแบบนี้ค่ะ
var color_1 = "<?=$bankokcolor;?>";
|
 |
 |
 |
 |
Date :
2010-11-26 00:04:33 |
By :
ultrasiam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
067.//var color_1 = <?=$bankokcolor;?>; //ติดที่ตัวนี้ครับ
อันนี้ผมไม่แน่ใจว่าเก็บข้อมูลแบบใหน กรณีที่เป็น color หรือเป็นข้อมูลที่เข้าข่ายว่าเป็น text
ให้ใช้ " "; ครอบตัวแปรไว้นะ
อันที่ว่ามีปัญหา ถ้าเก็บในรูปแบบสีปกติคือ #ffaabb แบบนี้ แก้ไขโดย แก้ไขได้โดยใส่ครอบฟันหนู
var color_1 = "<?=$bankokcolor?>";
แค่นี้หละ..
|
 |
 |
 |
 |
Date :
2010-11-26 00:08:34 |
By :
เต่าน้อย |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับเก็บเป็น text จริงๆ
|
 |
 |
 |
 |
Date :
2010-11-26 01:20:20 |
By :
airzio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|