製品 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;
}
}
?>
DB クエリ クラス
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;
}