i have a problem with dynamic table. In my project, i have to display dynamic column and row. for example, when user would like to have report from january to may and from year 2000 till 2008, the system will auto generate the table with those information...
kindly please help as this is very urgent project.
thanx
thanx for replying...actually i need to do some statistic from the result displayed.before creating the statistic, i have to collect and display the total of date received for the specific range of month and year. basically this will be the outcome:
year/ 2006 2007 2008 2009 TOTAL
month
JAN 1 0
FEB 3 0
MAC 4 1
TOTAL 8 1
hope this will give u the clear picture...
hope to hear from u soon...
Thank you for your replied..please refer attached file for the ouput. I would like to have column next to month is year that user selected. for example from 2008 - 2010...
scenario:when user select month from january to december and year from 2008 to 2010, the system will display how many date received on particular month and year..hope it clear.I post some of the coding of my project.
i'm quite new with php and not really familiar with object oriented...if you have an idea,kindly please respond on how to solve it..Thanx..i need this to be done quite urgent..thanx one more time...=)
//We will place these results into a table, build table. echo '<table cellpadding="0" cellspacing="0" border="1">'; //Lets make it nice, and add table headers. echo '<th>Month</th>';
//We will dynamically create the headers after the month //Using $i as a control so we don't lose the value of $tahun. $i = $tahun; while($i <= $tahun2) { echo '<th>'.$i.'</th>'; $i++; }
//Pull the data and store it in an array, so we can sort our $query. while ($row = mysql_fetch_array($result)) { $dbMonth = $month[$row[0] - 1]; $dbYear = $row[1]; $count = $row[2];
$storedMonth["$dbMonth"]["$dbYear"] = $count;
} //cycle through our array to build our table rows. foreach($storedMonth as $key => $value) { echo '<tr><td width="100">' . $key . '</td>';
//Since we are using a multi-dimensional array, we //want to cycle through our years we searched by //re-using $i so as not to lose our $tahun data //Use the FOR method, so we can populate <td> that //doesn't have a key inside the array. for ($i = $tahun; $i <= $tahun2; $i++) { echo ($storedMonth[$key][$i] == NULL) ? '<td width="100">0</td>' : '<td width="100">'.$storedMonth[$key][$i].'</td>'; } echo '</tr>'; }
echo '</table>';
?>
Last edited by Jcbones; 03-21-09 at 04:18 PM.
Reason: remove extra tags.