php - How to include select query for javascript? -
i have developed jvector map.now working fine.its showing details well.now want show country details database.its file javascript.finally have decided , create php database file
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 countrydetails 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); ?>
i have created simple database in mysql workbench. 1 canada north america none giovanni facciponte approved 2 india row none ritika balaji require approvel
now display data country here post india country details case 'india' :
label.html("country:  india
category:  requires approval
pdp gco region:  row
comments:  country complex
ccl:  ritika bajaj"); break;
here ajax code:
<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; } });
but want details database? how please me ?
Comments
Post a Comment