出於某種原因,我無法檢索我想要的出價信息。我希望它顯示當前項目的所有出價。 db,query或php有問題嗎? 其他功能工作,只是bid[bidprice]
沒有。當我設法得到它,以顯示它不會顯示等Mysql問題 - 功能不起作用
/*
============
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;
}
}
你得到的錯誤是什麼 – PSR 2013-04-08 10:35:08
它不會給出任何錯誤? – 2013-04-08 10:35:17
通常,當我面臨這個問題時,我複製$ qry與示例$ id(在這種情況下),並嘗試從mysqlworkbench或類似的運行它,這樣你可以放棄,如果它的PHP或MySQL的不好 – aleation 2013-04-08 10:35:22