Current location: Hot Scripts Forums » Programming Languages » PHP » 2d Table


2d Table

Reply
  #1 (permalink)  
Old 02-12-10, 03:04 PM
protocode protocode is offline
Newbie Coder
 
Join Date: May 2009
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
2d Table

I have pulled information from my database. I need to display that information in a table with two identifiers, a row and column. Example

+-------+-------+-------+
| | 2009 | 2010 |
+-------+-------+-------+
| Jan. |(count)|(count)|
+-------+-------+-------+
| Feb. |(count)|(count)|
+-------+-------+-------+
I can query the information correctly, but displaying it is way off.

Thanks for any hints or suggestions in advance.
Reply With Quote
  #2 (permalink)  
Old 02-12-10, 03:51 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Please post your code.
Reply With Quote
  #3 (permalink)  
Old 02-12-10, 08:53 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
PHP Code:


while($r mysql_fetch_assoc($result)) {
  
$myArray['Month'][$r['year']] = $r['year'];
  
$myArray[$r['month']][$r['year']] = $r['count'];
}
echo 
'<table border="1">';       
foreach(
$myArray as $month => $v) {
  echo 
'<tr><td>' $month '</td>';
   foreach(
$v as $year => $count) {
     echo 
'<td>' $count '</td>';
   }
 echo 
'</tr>';

More code, gets more accurate answers.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MYSQL database countll Database 2 06-19-07 04:20 PM
What do you think of my database structure? Oskare100 Database 5 12-27-06 07:43 AM
Pretty simple ( i think) question any help!?!? 0o0o0 PHP 2 04-07-06 10:47 AM
Problem with a sort table js function tdubyou JavaScript 0 05-03-04 09:19 AM
auto table resize derick_2k JavaScript 4 04-26-04 02:32 PM


All times are GMT -5. The time now is 08:10 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.