I am using mysql database for my phonegap app
but phonegap don’t support php language ..
var input = $(‘#input’);
$.ajax({
url: 'http://localhost/postdetail/photo.php',
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
success: function(data, status){
$.each(data, function(i,item){
var photo = '<h1>'+item.name+'</h1>'
+ '<p>'+item.id+'<br>'+
'<h3>'+item.img+'</h3><br>'+
'<img src="'+item.img+'">';
input.append(photo);
});
},
Blob Image in Mysql Don’t Display .. plese Help Me
my php script
<?php
header('Content-type: application/json');
$server = "localhost:3306";
$username = "root";
$password = "12345";
$database = "photos";
$con = mysql_connect($server, $username, $password) or die ("Could not connect: " . mysql_error());
mysql_select_db($database, $con);
$sql = "SELECT id, name AS name, img AS img FROM n ORDER BY name";
$result = mysql_query($sql) or die ("Query error: " . mysql_error());
$records = array();
while($row = mysql_fetch_assoc($result)) {
$records[] = $row;
}
mysql_close($con);
echo $_GET['jsoncallback'] . '(' . json_encode($records) . ');';
?>
Thanx
If you’re trying to embed the image directly, you’ll need to use the
data:formatOr in your case: run
base64_encode()on your blob in your php script, then do this in your javascript:Of course, you’ll need to make sure the mime type matches; if you aren’t using pngs exclusively, you’ll have to pass along the mime type as well in your ajax response.