通过PHP和Javascript实现智能输出

I am stuck and could not found any solutions from web and I am not sure how to construct the coding through PHP/Javascript and MySql. The thing is that, I have a Table (Table-1) with

Table-1

Colour  Barcode Quantity
Blue    123456  25
Red     234859  35
Black   238402  60
Yellow  238492  50

Now I want an output of 4 colours on a page based on quantity ration MAX two rows X 4 colour format.

Example:

First Page (say):

Blue    Red Black   Black
Black   Black   Yellow  Yellow

Second Page (say):

Blue    Red Black   Black
Black   Yellow  Yellow  Yellow

And so on.

This is I am trying to achieve from a long time but could not get from where to start because I am not very good a PHP and Java script. Any help will be kind enough to complete my project Thanks Sagor