|
|
|
getJSON แต่ข้อมูลไม่ออกมาเลย เขียนโค๊ดผิดตรงใหนเหรอคะ |
|
|
|
|
|
|
|
function addMark(markID) {
var str = './serverside/point_avr_get.php?qtype=mark&mark_id=' + markID + '&' + jQuery.now();
$.getJSON( str, function(rec) {
$.each(rec.mark, function(j, item) {
var newpoint = new OpenLayers.Geometry.Point(item.lon, item.lat);
var newPoint = [];
g_line_oldpoint[markID] = newpoint;
m_lon = item.lon;
m_lat = item.lat;
});
var lonlat_get = new OpenLayers.LonLat(m_lon , m_lat);
var pic_get = 'images/talk.png';
var sz = new OpenLayers.Size(34, 25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon_get = new OpenLayers.Icon(pic_get, sz, null, offset);
m_marker_get[markID] = new OpenLayers.Marker(lonlat_get, icon_get);
m_markers.addMarker(g_marker_get[markID]);
});
อันนี้ไฟล์แสดงผล
Code (PHP)
<?
include("gbvar.php");
?>
<?
$g_qtype = $_GET['qtype'];
$g_carid = $_GET['car_id'];
$mark = $_GET['mark'];
$mark_id = $_GET['mark_id'];
$con = mysql_connect($db_host, $db_user, $db_pass) or die('Could not connect: ' . mysql_error());
mysql_select_db($db_name, $con) or die('Could not select database');
if ( $g_qtype == "realtime" ) $query = "SELECT * FROM cars WHERE id = '$g_carid'";
else if ( $g_qtype == "log" ) {
$g_dtstart = $_GET['dt_start'];
$g_dtend = $_GET['dt_end'];
$g_dtstart = str_replace('%20', ' ', $g_dtstart);
$g_dtend = str_replace('%20', ' ', $g_dtend);
$query = "SELECT gps_lon, gps_lat, car_picture FROM point_log WHERE ( dt_post BETWEEN '$g_dtstart' AND '$g_dtend' ) AND ( car_id = '$g_carid' )";
}
else if($g_qtype=="mark")
{
$query="select * from mark where mark_id='$mark_id'";
}
$result = mysql_query($query) or die('Query failedqqqqq: ' . mysql_error());
$arr = array();
if ( mysql_num_rows($result) != 0 ) {
while($row=mysql_fetch_assoc($result)) {
$arr[] = $row;
}
header('Content-type: application/json');
if ( $g_qtype == "realtime" ) echo json_encode(array('cars'=>$arr));
else if ( $g_qtype == "log" ) echo json_encode(array('point_log'=>$arr));
else if ( $g_qtype == "mark" ) echo json_encode(array('mark'=>$arr));
}
mysql_free_result($result);
mysql_close($con);
?>
ส่วนนี่ไฟล์ที่select ข้อมูลส่วไปยังไฟล์แรก
Tag : PHP, MySQL, JavaScript, jQuery
|
|
|
|
|
|
Date :
2012-04-24 11:38:24 |
By :
tai_kook |
View :
984 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเรียกตัวที่เป็น php ครับ มี error หรือเปล่าครับ
|
|
|
|
|
Date :
2012-04-26 11:41:26 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|