我想从数据库中查询某些内容但它根本不返回任何值。我想知道为什么它没有报告任何错误。请检查附件。
这是我制作的代码。谢谢。
echo '<form method = "post" action = "http://localhost:8080/nbm/delivery/show_delivery_details.php">';
$nbm = new Db();
$poid = $_GET['id'];// this was taken from the previous page
echo $poid;//tried to display this and it does
$get_deliveries= $nbm->query("SELECT * FROM `customer_order_list` where purchase_order_id = '$poid'");
foreach($get_deliveries as $key){
echo $key['purchase_order_id'].' '.$key['customer_id'].' '.$key['amount'];
}
print_r($get_deliveries);//also tried this but it displays nothing
echo '</form>';
答案 0 :(得分:1)
$
答案 1 :(得分:0)
<?php
$nbm = new Db();
$poid = $_GET['id'];
$get_deliveries= $nbm->query("SELECT * FROM `customer_order_list` where purchase_order_id = '$poid'");
echo '<form method = "post" action = "show_delivery_details.php">';
foreach($get_deliveries as $key){
echo $key['purchase_order_id'].' '.$key['customer_id'].' '.$key['amount'];
}
echo '</form>';
&GT;
尝试在foreach循环中打印$ key变量。而不是print_r使用var_dump($ var);
答案 2 :(得分:0)
首先使用db中的get $ poid值首先执行查询。
SELECT * FROM `customer_order_list` where purchase_order_id = '$poid'
然后在$ res = $ nbm-&gt;查询(SELECT * FROM customer_order_list
,其中purchase_order_id ='$ poid')。你想要获取结果。
mysql_fetch_result($res);
检查你是否这样做了。