Yii Framework Forum: Horizontal And Vertical Presentation Of Db Table - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Horizontal And Vertical Presentation Of Db Table Rate Topic: -----

#1 User is offline   yii_king 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 107
  • Joined: 05-August 12

Posted 08 March 2013 - 03:37 PM

How can I retrieve a row from a database and print it out both horizontally and vertically?

I have a table which contains data in the following columns:

Quote

id, name, date, hour1, hour2, hour3


The data in the table is:

Quote

1, bmw, 2013-03-08, 1, 2, 3
2, audi, 2013-03-09, 4, 5, 6
1, bmw, 2013-03-09, 8, 10, 11


When I retrieve these values from the database I want to print out like this:

Quote

<table>
<thead>
<th>ID</th><th>Name</th><th>2013-03-08</th><th>Hour1</th><th>Hour2</th><th>Hour3</th><th>2013-03-09</th><th>Hour1</th><th>Hour2</th><th>Hour3</th>
</thead>
<tbody>
<tr>
<td>1</td><td>bmw</td><td>1</td><td>2</td><td>3</td><td>8</td><td>10</td><td>11</td>
</tr>
<tr>
<td>2</td><td>audi</td><td><td></td><td></td><td>4</td><td>5</td><td>6</td>
</tr>
</tbody>


Any ideas of how to achieve this in a foreach loop?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users