Click here to Skip to main content
15,937,447 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created Map in Jvector map.its working. i did many customization.Now i want display country details from database. i created simple database for two country and connect mysql using how to connect php database in ajax using jquery?

simple database:

'1', 'canada', 'North America', 'None', 'Giovanni Facciponte', 'Approved'

My php database code:

$host = "localhost";
$port = 3306;
$user = "root";
$password = "";
$dbname = "mydatabase";


$con = new mysqli($host, $user, $password, $dbname, $port, $socket)
or die ('Could not connect to the database server' . mysqli_connect_error());


$query = "SELECT countryId, country, pdogcoregion, comments, ccl, category
FROM countrydetails
WHERE country='canada' ";
$countrydetails = '';

$stmt->bind_param('s', $countrydetails);

if ($stmt = $con->prepare($query)) {

$stmt->bind_result($countryId, $country, $pdogcoregion, $comments, $ccl, $category);

while ($stmt->fetch()) {




My script code:

var $ = jQuery;
$('#map1').vectorMap('set', 'focus', {region: 'AU', animate: true});
$('#map1').vectorMap('set', 'focus', {regions: ['AU', 'JP'], animate: true});
$('#map1').vectorMap('set', 'focus', {scale: 7, lat: 35, lng: 33, animate: true});
$('#map1').vectorMap('set', 'focus', {scale: 1, x: 0.5, y: 0.5, animate: true});
map: 'world_mill_en',
panOnDrag: true,
focusOn: {
x: 0.5,
y: 0.5,
scale: 1,
animate: true
series: {
regions: [{
scale: ['#688FA0'],
normalizeFunction: 'polynomial',
values: {
onRegionClick: function (event, code) {
var map = $('#map1').vectorMap('get', 'mapObject');
var name = map.getRegionName(code);

$(document ).ready(function() {
type: "GET",
contentType: 'application/x-www-form-urlencoded',
url: 'database.php',
data: {country: 'canada'},
dataType: "text",
success: function(data){

its my code .i don't know where i did mistake ?please any one find my code mistake ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900