这是我的javascript代码:
$(document).ready(function() {
$('.aire-force,.army').click(function() {
var storedData;
var qString = 'categorie=' +$(this).text();
$.post('getimage.php', qString, processResponse);
});
function processResponse(data) {
$('.results').html(data);
storedData = data;
alert(storedData);
document.getElementById('test').innerHTML = test;
}
});
这是我的文件PHP(getimage.php):
<?php
$con = mysql_connect("localhost","root","");
if(!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("DB", $con);
$categorie = $_POST['categorie'];
$q = "SELECT title from designs WHERE categorie='$categorie'";
$r = mysql_query($q);
while( $array = mysql_fetch_array($r)){
echo $array['title'];
}
?>
我需要在我的代码HTML中获取图像块:
require_once('getimage.php');
<img src="images/ echo $array['title']; />
答案 0 :(得分:0)
require_once('getimage.php');
< img src="images/ echo $array['title']; />
应替换为:
<?php include('getimage.php'); ?>
<img src="images/<?php echo $array['title']; ?>" />
这应该有效..将此html文件也保存为.php;)
答案 1 :(得分:0)
document.getElementById('test').innerHTML = test;
您永远不会设置测试变量。