mercredi 3 août 2016

How do I randomly display categories in a particular order

I have an online store,where the members can subscribe to any of the 3 packages (1, 2 & 3). Below is a sample of the Products DB table.

  • id package product status
  • 1 3 Biro 1
  • 2 1 Paper 1
  • 3 3 Pin 0
  • 4 2 Eraser 1
  • 5 2 Blade 1
  • 6 3 Bag 1
  • 7 2 Pen 0
  • 8 1 Sharpener 1
  • 9 1 Shoe 1
  • 10 2 Chair 1

I displayed the package 3 products first, then package 2 products next then package 1 products last like this;

$get_products = mysql_query("SELECT * FROM products WHERE status='1' ORDER BY package DESC");

But what i want to really do is to randomly display all package 3 products first, then randomly display package 2 products and lastly display package 1 products randomly. So that no particular item will always be at the top while some will always be on the bottom.

How do I write the syntax. Thanks in advance




Aucun commentaire:

Enregistrer un commentaire