0
只显示真正的布尔值我有以下的表:js脚本从MySQL数据库
Name,
Quantity,
Price,
Option1 (bool),
Option2 (bool)
是我在一个简单的网页使用PHP,JS和jQuery显示。尽管脚本可行,但我试图找到一种方法来仅显示非布尔(名称,数量和价格)和true-bool值。这是工作js脚本:
$(document).ready(function() {
done();
});
function done() {
setTimeout(function() {
updates();
done();
}, 200);
}
function updates() {
$.getJSON("fetch.php", function(data) {
$("ul").empty();
$.each(data.result, function(){
$("ul").append("<li>Name: "+this['name']+"</li><li>Quantity: " + this['quantity']+"</li><li>Price: "+this['price']+"</li><li>Option1: "+this['option1']+"</li><li>Option2: "+this['option2']+"</li><br />");
});
});
因为我几乎没有js的经验,任何帮助将不胜感激!
这里是我的,供大家参考fetch.php脚本:
<?php
include_once('db.php');
$sql = "SELECT * FROM people";
$res = mysql_query($sql);
$result = array();
while($row = mysql_fetch_array($res))
array_push($result, array(
'name' => $row[0]));
'quantity' => $row[1],
'price' => $row[2],
'option1' => $row[3],
'option2' => $row[4]));
echo json_encode(array("result" => $result));
?>
谢谢!