我是posgreSQL和JSON的新手,需要一些帮助来编写查询。我有一张桌子,可以在商店里存储一些购买历史记录。示例表如下:
------------------
| shoe | pants |
-----------------
| 3 | 4 |
我想编写一个查询来计算所有 bob 的购买量,并创建如下输出:
<?php
session_start(); // start the session
if(isset($_SESSION['random'])) {
$x = $_SESSION['random'];
} else {
$x = rand(5,50);
$_SESSION['random'] = $x;
}
echo $x."<br><br>";
echo "Enter the number you see above:";
function form1 () {
function test_input_1($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<form id="question1" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="post">
<input type="text" name="user_input1" value="<?php if(isset($_POST['user_input1'])) { echo htmlentities ($_POST['user_input1']); }?>"/><br>
<input type="submit" name="user_input1Submit" style="position: absolute; left: -9999px"/>
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['user_input1'] !="") {
$user_input1 = test_input_1($_POST["user_input1"]);
// more variables here, per line -- and add them to the ="" above.
return $user_input1;
}
}
}
form1();
输出形式并不重要。像''鞋':3'裤子':4}也是如此。谢谢你提前。