由于某种原因,我无法从投标中检索我想要的信息。我希望它显示当前项目的所有出价。db、query 或 php 有问题吗?其他功能起作用,只是bid[bidprice]
不起作用。当我试图让它显示它不会显示等。
/*
============
db class
============
*/
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 $bid;
} else {
echo 'Error Executing Query';
}
return false;
}
/*
============
html php
============
*/
<?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>';
foreach($this -> bidprice as $val)
{
$html .= '<p> Bid Price'.$val['bidPrice'].'</p>';
$html .= '<p> Bidded By'.$val['userName'].'</p>';
}
$html .= '</div>';
$html .='<div id="space">';
$html .='</div>';
return $html;
}
}