我已经开发了Jvector map.Now正常工作。显示详细信息。现在我想从database.its显示国家详细信息所有文件javascript.Finally我已经决定并创建php数据库文件
database.php中
<?php
Content-Type: application/json;
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "mydatabase";
$link = mysql_connect($dbhost, $dbuser, $dbpass)
or die('Could not connect: ' . mysql_error());
mysql_select_db($dbname) or die('Could not select database');
$query = "SELECT countryId,country,pdogcoregion,comments,ccl,category FROM countrydetails WHERE Country='Canada';
";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$all_recs = array();
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$all_recs[] = $line;
}
echo json_encode($all_recs);
mysql_free_result($result);
mysql_close($link);
?>
我在mysql workbench中创建了Simple数据库。 1加拿大北美没有Giovanni Facciponte批准 2印度ROW无Ritika Balaji要求批准
现在显示所有国家的数据看起来像这里我发布印度国家详细信息 案例'印度':
label.html(“国家/地区:&amp; nbsp India 类别:&amp; nbsp需要批准 PDP GCO地区< / b>:&amp; nbsp ROW
评论:&amp; nbsp这个国家很复杂 CCL :&amp; nbsp Ritika Bajaj“);
打破;
这里是ajax代码:
<script>
jQuery.noConflict();
jQuery(function(){
var $ = jQuery;
$('#focus-single').click(function(){
$('#map1').vectorMap('set', 'focus', {region: 'AU', animate: true});
});
$('#focus-multiple').click(function(){
$('#map1').vectorMap('set', 'focus', {regions: ['AU', 'JP'], animate: true});
});
$('#focus-coords').click(function(){
$('#map1').vectorMap('set', 'focus', {scale: 7, lat: 35, lng: 33, animate: true});
});
$('#focus-init').click(function(){
$('#map1').vectorMap('set', 'focus', {scale: 1, x: 0.5, y: 0.5, animate: true});
});
$.ajax({
type: "GET",
url: "database.php",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{country : country}",
success: function(data){
sr = data;
}
});
但我想从数据库中获取此详细信息?我该怎么做请帮助我?