A better way to display this data from MySql using php -


i have data in table:

id  |  type ------------ 1   |  1 2   |  1 3   |  2 4   |  2 5   |  3 6   |  3 6   |  3 

i need display data this:

type 1 --all type ones go here type 2 -- type twos go here type 3 type threes go here 

the way right using 2 separate sql statements , loops.

select distinct type type table while() {  select type table type = type;  while()  {   } } 

is there better way , results want, or using 2 loops way?

  1. change query using order type asc.
  2. loop through results, build associative array key type, , values ids.

now have 1 loop, , ids can accessed type associative array. should trivial loop through array key, , show ids key.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -