我写了这段代码,它应该用用户兑换的所有代金券和它们的价值制作一个表格,但它不起作用(根本没有出现,也没有显示任何错误)所以我很困惑我在这里做错了什么. 有人可以帮忙吗?$dsn = 'mysql:host=127.0.0.1;dbname=user_db;charset=utf8';$conn = new PDO($dsn, $username1, $password);$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);$stm_voucher = $conn->prepare("SELECT id FROM users WHERE username = :username");$stm_voucher->bindParam(":username", $username, PDO::PARAM_INT);$stm_voucher->execute();while ($row = $stm_voucher->fetch(PDO::FETCH_ASSOC)) { $id = $row["id"]; $stm_voucher2 = $conn->prepare("SELECT * FROM vouchers WHERE used_by = :id"); $stm_voucher2->bindParam(":id", $id, PDO::PARAM_INT); $stm_voucher2->execute(); $rank = 1; while ($row2 = $stm_voucher2->fetch(PDO::FETCH_ASSOC)) { echo "<tr> <td>{$rank}</td> <td>{$row2['voucher']}</td> <td>{$row2['value']}</td> <td>{$row2['used_on']}</td> </tr>"; $rank++; }}
添加回答
举报
0/150
提交
取消