获取数据库时,我得到了结果,一切正常,我从数据库中得到了一个价格,这也是可行的,但我真正需要的是,如果返回的价格为 0,那么“0”应该替换为“POD” “ 反而。
任何帮助表示赞赏。
这是我的查询代码:
$samples = "SELECT * FROM materials, category_price WHERE materials.type = :cat AND materials.supplier = '$supplier' AND materials.category_id = category_price.category_id";
$res = $db->prepare($samples);
$res->execute(array(':cat' => $category));
$count = $res->rowCount();
if($count > 0)
echo "
<section class=\"border mar_t_40\">
";
while ($row = $res -> fetch()){
$postimggranite = $row[image];
$postidgranite = $row[id];
$postname = $row[mat_name];
$folder = $row[type];
$folder = strtolower($folder);
$supplier = strtolower($supplier);
$category_id = $row[category_id];
$price = ("£ ".$row[price]);
print<<<END
<span class="grid white_back mar_l_30">
<h3>$price</h3>
<a class="fancybox" href="$img_path/$folder/$supplier/large/$postimggranite" rel="group[$postidgranite]" title="$postname"><img alt="$row[name]" src="$img_path/$folder/$supplier/small/$postimggranite" width="100" height="100">$postname</a>
</span>
END;
}
echo "<div class=\"clearfloat\"></div></section>";