...

View Full Version : report chart using multidimensional array in php and mysql



prithvi.web
02-02-2010, 10:00 PM
Hi,

This is my first post here.Anyway I am trying to achieve a html table like below,


timeslots User1 User2 User3 User4
8am-9am work work work work

9-10

10-11

...
...
...

17-18

where tmeslots are the different timings from morning to night.user1,2,3 are the usernames and work=work done on that certain period.

My table structure and table data


CREATE TABLE IF NOT EXISTS `report` (
`rid` int(11) NOT NULL auto_increment,
`admin_id` int(11) NOT NULL,
`which_day` date NOT NULL,
`start_time` varchar(255) NOT NULL,
`end_time` varchar(255) NOT NULL,
`activity` text NOT NULL,
`total_value` int(11) NOT NULL,
PRIMARY KEY (`rid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `report`
--

INSERT INTO `report` (`rid`, `admin_id`, `which_day`, `start_time`, `end_time`, `activity`, `total_value`) VALUES
(1, 25, '2010-02-01', '2010-02-01 5:42 PM', '2010-02-01 5:52 PM', 'sdsd', 10),
(2, 22, '2010-02-02', '2010-02-02 2:47 PM', '2010-02-02 2:55 PM', 'dsdsds', 8),
(3, 24, '2010-02-02', '2010-02-02 1:47 PM', '2010-02-02 2:47 PM', 'sdsdsdsdsd', 60),
(4, 23, '2010-02-02', '2010-02-02 1:30 PM', '2010-02-02 2:48 PM', 'sdsdsd', 78),
(5, 25, '2010-02-02', '2010-02-02 3:34 PM', '2010-02-02 3:40 PM', 'dsdwew', 6),
(6, 25, '2010-02-02', '2010-02-02 3:25 PM', '2010-02-02 3:35 PM', 'cdsfdfdfd', 10);

You see its a activity generating for different period of time.admin_id is a foreign key here.I have joined this key with another table that is admin_table where the usernames are kept.

Now please suggest me..with this table structure will i be able to achieve the html table structure using multidimensional array.

I have a array structure in mind..which is


Array
(
[az] => Array
(
[dsdsds] => Array
(
[2010-02-02 2:47 PM 2010-02-02 2:55 PM] => 8
)

)

[an] => Array
(
[sdsdsdsdsd] => Array
(
[2010-02-02 1:47 PM 2010-02-02 2:47 PM] => 60
)

)

[mu] => Array
(
[sdsdsd] => Array
(
[2010-02-02 1:30 PM 2010-02-02 2:48 PM] => 78
)

)

[raj] => Array
(
[dsdwew] => Array
(
[2010-02-02 3:34 PM 2010-02-02 3:40 PM] => 6
)

[cdsfdfdfd] => Array
(
[2010-02-02 3:25 PM 2010-02-02 3:35 PM] => 10
)

)

)

I don't know if I am going in correct path.Please help.

Thanks in advance,
Raj



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum