Advertisement
Guest User

random products

a guest
Jul 16th, 2012
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <?php
  2. $i=0;
  3. $pieces = explode(" ", $products_name);
  4. $productname=$pieces[1]." ".$pieces[2];
  5. $productname1="%".$productname."%";
  6. $productname2="%".$pieces[1]."%";
  7. $productname3="%".$pieces[0]."%";
  8. $query="select * from products_description where products_name LIKE '$productname3' OR '$productname1' OR '$products_name' limit 0,$popular_at_shop";
  9. //$query="select * from products_description where products_name like '$productname1' or '$productname2' or '$productname3' limit 0,$popular_at_shop";
  10. $qry=mysql_query($query);
  11. $qry1=mysql_num_rows($qry);
  12. if($qry1>0)
  13. {
  14. ?>
  15. <?php
  16. while($result=mysql_fetch_array($qry))
  17. {
  18. if($i==0 || $i%3==0)
  19. {
  20. echo '<tr valign="top">';
  21. }
  22. echo '<td align="center" width="300px;" style="padding-left:20px; padding-top:10px; padding-bottom:10px;">';
  23. ?>
  24.  
  25. <a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $result['products_id']); ?>"><div class="popularatshop"><?php echo substr($result['products_name'],0,28); ?>...</div></a>
  26.  
  27. <?php
  28.  
  29. if (($i+1)%3==0)
  30. {
  31. echo '</td></tr>';
  32. }
  33. $i++;
  34.  
  35. }
  36.  
  37. }
  38.  
  39. echo '</table></td></tr><tr>';
  40. ?></div>
  41. <div>
  42.  
  43. </div>
  44. <!-- End Wrapper -->
  45. <?php
  46. if (isset($HTTP_GET_VARS['products_id'])) {
  47. $i=0;
  48. $id=$HTTP_GET_VARS['products_id'];
  49.  
  50. /*
  51. $orders_query = mysql_query("select p.products_id, p.products_image from orders_products opa, orders_products opb, orders o, products p where opa.products_id = '$id' and opa.orders_id = opb.orders_id and opb.products_id != '$id' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit 0,$also_purchase_limit");
  52. */
  53.  
  54. $orders_query = mysql_query("select p.products_id, p.products_image from products p, categories c, products_to_categories ptc where p.products_id = ptc.products_id and c.categories_id = ptc.categories_id and c.categories_id in (select categories_id from products_to_categories where products_id = '$id') order by rand() limit 0, 21");
  55.  
  56. $also1=mysql_num_rows($orders_query);
  57. if($also1>0)
  58. {
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement