0

我正在尝试通过此 if 语句中继 id 以查看文件是否存在。如果是这样,我想使用 id 从公司徽标/文件夹中获取该图像。如果不是,我想简单地显示一个默认图像。我不知道它是否捕获了 id,因为它一直在吐出默认值。

   if ($productCount > 0) {
        // get all the product details
        while($row = mysql_fetch_array($sql)){ 
        $id = $row["id"];
    $imgStock="http://www.stocksandstocks.com/corporation-logos/$id.jpg";
    $http_image="http://www.stocksandstocks.com/images/no-logo-default.png";

if(file_exists($imgStock))
{
  $imgPick = "$imgStock";
}
else
{
  $imgPick = "$http_image";
} 
echo "
                    <ul>
                        <li>
                               <div class='wrapPicks'>
                                  <div class='symbolPicks'>
                                      <div class='quoteTitle'>$quoteTitle</div>
                                      </div>
                                      <div class='bgPicks'>
                                      <img src='$imgPick' height='50px' widht='80px' alt='stock symbol $quoteTitle logo' />
                                                <div class='separateWrap'>
                                                      <div class='quote'>
                                                          <b>Entry Price:</b> $$entry
                                                      </div>
                                                      <div class='quote'>
                                                          <b>Last trade:</b> $$lastPrice
                                                      </div>
                                                </div>    
                                                      <div class='quoteReturn'>
                                                              <b>Open P/L:</b> 
                                                              <div class='bigGreen'>
                                                              <span style=\"color: $color\">$positive $$profit </span>
                                                              </div>
                                                      </div>
                                 </div>
                            </div>
                    </li>
                </ul>";
4

0 回答 0