出于某种原因,“价格”返回 null 而其他所有都不是问题。任何想法为什么会这样?
MySQL:
名为“nights”的表,列名为“name”、“price”、“day”、“queue jump”、“closures”和“doors”。他们都是人口稠密的。
事件信息.php:
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
include('functions.php');
connect();
$night = $_POST['club'];
$night = mysql_real_escape_string($night);
$query = "SELECT * FROM nights WHERE name = '" .$night. "'";
$result = mysql_query($query);
$items = array();
if($result && mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
$items[] = array("price"=>$row['price'], "day"=>getLongDateString($row['day']), "queuejump"=>$row['queue jump'], "closing"=>$row['closing']);
}
}
mysql_close();
// convert into JSON format and print
echo json_encode($items);
?>
JS:
<script type="text/javascript">
$(document).ready(function() {
$('#right_inside').html('<h2>' + $('#club').val() + '</h2>');
});
$('#club').change(function(event) {
$.ajax({
type: "post",
url: "eventinfo.php",
data: $(this).serialize(),
success: function(data) {
$('#right_inside').html('<h2>' + $('#club').val() + '<span style="font-size: 14px"> (' + data[0].day + ')</h2><p>Entry: ' + data[0].price + '</p><p>Queue jump: ' + data[0].queuejump + '</p><p>Guestlist closes at ' + data[0].closing + '</p>');
alert(JSON.stringify(data));
},
dataType: "json"
});
});
</script>