我正在尝试获取所有通过产品 ID 提交和传递的投标金额,我似乎无法让它工作,谁能告诉我我做错了什么?
我已将视图类放置在它的输出上,并将查询放置在 DB 类上
我要做的是通过传递用户点击产品的链接从投标表中获取所有投标并输出到屏幕
<?php
class ProductView extends View {
protected function displayContent() {
if(isset($_GET['id'])) {
//get the record from database
$this -> product = $this -> model -> getProductByID($_GET['id']);
$this -> bidprice = $this -> model ->allbids($_GET['id']);
if(is_array($this -> product)) {
$html = $this -> displayProduct();
} else {
$html .= '<p>Sorry, that product is not available</p>';
}
} else {
header("Location:index.php?page=error");
}
return $html;
}
private function displayProduct() {
$html = '<div id="product">';
$html .= '<img src="images/products/'.$this -> product['productImage'].'" alt="'.$this -> product['productName'].'" />';
$html .= '<h3>'.$this -> product['productName'].'</h3>';
$html .= '<p><strong>$'.$this -> product['productPrice'].'.00'.'</strong></p>';
//.sprintf("%.2f" result was breaking the query placed .00. to give it currency rate.
$html .= '<p>'.$this -> product['productDescription'].'</p>';
$html .= '<p>'.$this -> bidprice['bidPrice'].'</p>';
$html .= '</div>';
$html .='<div id="space">';
$html .='</div>';
return $html;
}
}
?>
数据库查询类
public function allbids($id){
$qry = "SELECT userName , bidPrice as bidPrice FROM bids , users WHERE productID = $id";
$rs = $this -> db -> query($qry);
if($rs) {
if($rs ->num_rows > 0) {
$bid = $rs -> fetch_assoc();
}
return $bidPrice;
} else {
echo 'Error Executing Query';
}
return false;
}