图像没有通过正确的产品

时间:2013-12-02 10:57:14

标签: php mysql sql

出于某种原因,我在每个产品上的图片都没有通过我网站的前端。 当您单击实际产品页面而不是index.php

时,它可以正常工作

http://www.tyresinwigan.co.uk/new/

<?php
require_once('const.php');
$link = dbConnect();

$query = "SELECT *, v.vehicle_id AS vehicle_id_alias 
FROM vehicle_tbl AS v, manufacturer_tbl AS m 
LEFT JOIN image_tbl AS i ON vehicle_id = i.vehicle_id 
WHERE v.manufacturer_id = m.manufacturer_id AND v.vehicle_feature2 = '1' 
GROUP BY v.vehicle_id ORDER BY RAND() LIMIT 1";

$result = false;
$result = mysql_query($query, $link);
$fmain = false;
if (($result) && (mysql_num_rows($result) > 0)) {
$fmain = mysql_fetch_array($result, MYSQL_ASSOC);
mysql_free_result($result);
}

$query = "SELECT *, v.vehicle_id AS vehicle_id_alias 
FROM vehicle_tbl AS v, manufacturer_tbl AS m 
LEFT JOIN image_tbl AS i ON vehicle_id = i.vehicle_id 
WHERE v.manufacturer_id = m.manufacturer_id AND v.vehicle_feature1 = '1' 
GROUP BY v.vehicle_id ORDER BY RAND() LIMIT 6";

$offers = false;
$offers = mysql_query($query, $link);

function nextOffer() {
    global $offers;
    if ($offers && ($row = mysql_fetch_array($offers))) {
    if (! isset($row['image_name'])) { // no image
        $image = 'images/noimagesml.jpg';
    } else {
        $image = 'images/vehicles/sml/'.stripslashes($row['image_name']);
    }
    $title = stripslashes($row['manufacturer_name']).' '.stripslashes($row['vehicle_model']);
    $price = number_format((float) $row['vehicle_price_pcm'], 2);
    $id = (int) $row['vehicle_id_alias'];
    echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td class="contenthead"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="11" height="40" align="left" valign="top"><img src="images/featre_left_hd.gif" width="11" height="23"></td>
                            <td width="100%" align="left" valign="middle" class="contenthead">'.$title.'</td>
                            <td width="11" height="40" align="right" valign="top"><img src="images/featre_rght_hd.gif" width="11" height="23"></td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td class="contentpane"><table width="100%"  border="0" cellspacing="5" cellpadding="0">
                          <tr>
                            <td align="center" valign="middle"><img src="'.$image.'" width="100" height="58" class="bordered" alt="'.$title.'"></td>
                          </tr>
                          <tr>
                            <td align="center" valign="top" class="princing">from just &pound'.$price.' pcm</td>
                          </tr>
                          <tr>
                            <td align="right" valign="middle"><a href="cardeal.php?vehicle='.$id.'"><img src="images/more_butt.gif" width="54" height="20" border="0"></a></td>
                          </tr>
                        </table></td>
                      </tr>
                    </table>';
    } else {
        echo 'Error!!';
    }
}

?>

1 个答案:

答案 0 :(得分:0)

尝试更改您的查询:

   SELECT *, 
          v.vehicle_id AS vehicle_id_alias 
     FROM vehicle_tbl AS v
     JOIN manufacturer_tbl AS m on v.manufacturer_id = m.manufacturer_id
LEFT JOIN image_tbl AS i ON v.vehicle_id = i.vehicle_id 
    WHERE v.vehicle_feature1 = '1' 
 GROUP BY v.vehicle_id 
 ORDER BY RAND() 
    LIMIT 6