这是我的 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']; />