我正在进行一个项目,我需要创建一个页面,在该页面中,用户帐户将能够将一定数量的“钱”转移到另一个注册帐户。 转账操作结束后,我需要一份交易记录。 我创建了一个包含所有事务的新数据库,但我不知道如何调用数据。
我尝试在 api.php 中使用它:
`//获取所有交易 案例“get_all_transactions”:
$cursor = $MySQLdb->prepare("SELECT * FROM transactions");
$cursor->execute();
$retval = "";
foreach($cursor->fetchAll() as $row){
if ($row["send_account"] == $user OR $row["recive_account"] == $user){
$retval = retval . "<br>"echo .$row['send_account']."<br>".$row['recive_account']."<br>".$row['amount'];
}else{
$msg = "nope";
}
}
echo '{"success":"true","data":"'.$retval.'"}';
die();
break;`
我在transaction.php页面中添加:
//get all transactions
$.post("api.php",{"action":"get_all_transactions"},function(data){
if(data.success == "true"){
$("#transactions_history").html(data.data);
}
});
我不知道如何继续。
有人可以帮忙吗?
如果你有任何其他方式,那就太好了。
谢谢!