How to create a two dimensional table

Valentino Lun
2009-01-14T10:12:35Z

Dear all

I have the following data in a table and I want to create a
2-dimensional table to display it.

Table: services
col01   col02   col03
AH   AS   1
AH   CS   2
AH   MS   3
BH   BS   1
BH   CS   1
BH   MS   1
CH   IS   1
CH   BS   2
CH   MS   1
DH   CS   1
DH   MS   1

I want to have this present on web

     AS  BS  CS  IS  MS
AH    1       2       3
BH        1   1       1
CH        2       1   1
DH            1       1


I only have the idea to display the column and row title. Can anyone
give me some idea how to generate this dynamically?. Thanks

controllers/dashboard_controller.rb
  def main
    @hospital_code = Service.find_by_sql("select distinct hospital_code
from services")
    @service_code =  Service.find_by_sql("select distinct service_code
from services")
  end


views/dashboard/main.html.erb



<% for s in @service_code %>
<%=s.col02 %>
<% end %>


<% for h in @hospital_code %>

<%=h.col01 %>

<% end %>


Many thanks
Valentino
--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org