我正在为我的 phonegap 应用程序使用 mysql 数据库,但 phonegap 不支持 php 语言..
var 输入 = $('#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);
});
},
Mysql中的Blob图像不显示..请帮助我
我的 php 脚本
<?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) . ');';
?>
谢谢