Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.95 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $result = array();
  2.  
  3.         $q = db_query("SELECT productID FROM ".SPECIAL_OFFERS_TABLE." ORDER BY RAND()") or die (db_error());
  4.        
  5.         while ($row = db_fetch_row($q))
  6.         {
  7.                 if (!isset($result[5])) {
  8.                         $q1 = db_query("SELECT productID, name, default_picture, Price, categoryID, seolink FROM ".
  9.        
  10.                                                 PRODUCTS_TABLE.
  11.        
  12.                                                 " WHERE productID=$row[0]") or die (db_error());
  13.        
  14.                         if ($row1 = db_fetch_row($q1))
  15.        
  16.                         {      
  17.        
  18.                                 if ( is_null($row1[2]) )
  19.        
  20.                                         continue;
  21.        
  22.                                 $picture = db_query( "select filename, thumbnail, enlarged from ".
  23.        
  24.                                         PRODUCT_PICTURES." where photoID=".$row1[2] );
  25.        
  26.                                 $picture_row = db_fetch_row( $picture );
  27.                                 if ( $picture_row )
  28.        
  29.                                 {
  30.        
  31.                                         if ( file_exists( "./products_pictures/".$picture_row[0] ) )
  32.        
  33.                                         {
  34.        
  35.                                                 $row1[2] = $picture_row[0];
  36.        
  37.                                                 $row1[3] = show_price($row1[3]);
  38.                                                
  39.                                                 $result[] = $row1;
  40.                                         }
  41.        
  42.                                 }
  43.        
  44.                         }
  45.                 }
  46.         }
  47.        
  48.         $smarty->assign("special_offers",$result);