1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<?php $formid=$_REQUEST['formid']; require_once "inc/configure.php";
$product_refid = (int)$_REQUEST['refid']; $product_itemno = filter_var($_REQUEST['itemno'], FILTER_SANITIZE_STRING); $width = setDefaultReqVar("width", 'style="width: 300px;"');
if($product_refid){ $sql = "SELECT * FROM inv_product_img WHERE product_refid=:product_refid ORDER BY CASE img_default WHEN 1 THEN 0 ELSE 1 END, refid DESC"; //echo $sql; $sth = $dbh->prepare($sql); $sth->execute( array(":product_refid"=>$product_refid) ); $row = $sth->fetch(); }elseif($product_itemno){ $sql = "SELECT dbo.inv_product_img.* FROM dbo.inv_product INNER JOIN dbo.inv_product_img ON dbo.inv_product_img.product_refid = dbo.inv_product.refid WHERE dbo.inv_product.itemno = :itemno ORDER BY CASE img_default WHEN 1 THEN 0 ELSE 1 END, dbo.inv_product_img.refid DESC"; //echo $sql; $sth = $dbh->prepare($sql); $sth->execute( array(":itemno"=>$product_itemno) ); $row = $sth->fetch(); //echo $sth->getSQL( array(":itemno"=>$product_itemno) ); } //echo $sth->getSQL(); if($row){?> <img src="<?=$row['img_path'].THUMB_PATH.$row['img_src']?>" <?=$width?> /> <?php } unset($sth);?>
|