| Newbie | | Join Date: Nov 2007
Posts: 8
| |
Hi All,
there are 4 different categories which each month will bw updated. In each category(source),there are many editions. I have to display 6months updates. its like one is month array which contains 6months' names.
source array contains source of that month.
$table_row conatins editions of particular source.
looking forward to get help from anyone
Thanks
Here is the code.. -
for($i=$current_month; ($num_displayed_months < 5) && ($i >= 0); $i--) {
-
$result_array = array();
-
$num_array = array();
-
$num_total = 0;
-
if($i == 0){
-
$i = $current_month;
-
$current_year = date("Y",mktime(0,0,0,$current_month,1,$current_year-1));
-
}
-
$array = array("Reviewes" => "systematic_reviews" , "Summaries" => "evidence_summary" , "Care Bundles" => "care_bundles" , "Best Practice Information Sheets" => "best_practice");
-
foreach($array as $source => $source_query) {
-
-
$query = "SELECT DISTINCT ID,Title,Authors,Source,Year,Date,pdfURL,htmlURL FROM (\n${$source_query}\n) AS `{$source_query}`\n WHERE Date LIKE '$current_year-%$i-%' ORDER BY Date DESC";
-
$result_array[$source] = mysql_query($query, $dblink) or die(mysql_error() );
-
$num_array[$source] = mysql_num_rows($result_array[$source]);
-
}
-
-
foreach ($num_array as $n) {
-
$num_total += $n;
-
}
-
-
if ($num_total == 0) continue;
-
-
$name = date("F",mktime(0,0,0,$i));
-
$month_text .= "<p><a href ='#$name'>New updates in $name $current_year</a></p>";
-
$month_array = array($month_text);
-
-
foreach($array as $source => $source_query) {
-
$result = $result_array[$source];
-
$num = $num_array[$source];
-
-
if($num){
-
$source_text .= "<p><a href = '#$source'>$source</a></p>";
-
$source_array = array($source_text);
-
-
-
$table_row = array();
-
$table_row[] = "<table class='pretty'>
-
<tr valign='bottom' class='header'>
-
<th>Id</th>
-
<th><p align='left'>Publication Title</p></th>
-
<th><p align='left'>Source</p></th>
-
<th><p align='left'>Authors</p></th>
-
<th><p align='left'>Year</p></th>
-
<th>Date</th>
-
<th>ViewPDF</th>
-
<th>ViewHTML</th>
-
</tr> ";
-
$alternate_row = false;
-
while($row = mysql_fetch_assoc($result)){
-
extract($row);
-
//output table
-
$trclass = ($alternate_row == true)? "even" : "odd" ;
-
$table_row[] = "<tr class = $trclass>";
-
-
$table_row[] = "<td>$ID</td>";
-
$title_URL = $ismember ? (is_null($htmlURL) ? $pdfURL : $htmlURL) : $dsURL;
-
-
$table_row[] = "<td><a href = '$title_URL' onclick='window.open('$title_URL'); return false;'>$Title</a></td>";
-
$table_row[] = "<td>$Source</td>";
-
-
$table_row[] = "<td>$Authors</td>";
-
-
$table_row[] = "<td>$Year</td>";
-
-
$table_row[] = "<td>$Date</td>";
-
if(is_null($pdfURL)){
-
$table_row[] = "<td align='center'>N/A</td>";
-
}
-
else{
-
$pdf_URL = $ismember ? $pdfURL : $dsURL;
-
-
$table_row[] = "<td><a href='<$pdf_URL' onclick='window.open('$pdf_URL'); return false;'><?= generate_img_tag('icon_small_pdf', 17, 17, NULL, 'icon17p') ?></a></td>";
-
-
//<?php
-
} // end if_else
-
if (is_null($htmlURL)) {
-
$table_row[] = "<td align='center'>N/A</td>";
-
}
-
else {
-
$html_URL = $ismember ? $htmlURL : $dsURL;
-
-
$table_row[] = "<td><a href='$html_URL' onclick='window.open('$html_URL '); return false;'><?= generate_img_tag('icon_small_pdf', 17, 17, NULL, 'icon17p') ?></a></td>";
-
-
//<?php
-
} #end if else(is_null($htmlURL))
-
$table_row[] = "</tr>";
-
$alternate_row = !$alternate_row;
-
}# end while()
-
-
$table_row[] = "</table>";
-
/*$display_array = array(
-
"month"=>$month_array,
-
"source"=>$source_array,
-
"table"=>$table_row
-
);
-
*/
-
/*$display_array = array(array(array($month_array)),
-
array(array($source_array)),
-
array(array($table_row))
-
);*/
-
//print_r($display_array);
-
$display_array = array($month_array=>array($source_array=>array($table_row)));
-
print_r($display_array);
-
}# end if($num)
-
}#end foreach()
-
$num_displayed_months++;
-
} #end for()
-
-
I have used below code to declare my multidimensional array..
-
/*$display_array = array(
-
"month"=>$month_array,
-
"source"=>$source_array,
-
"table"=>$table_row
-
);
-
*/
-
/*$display_array = array(array(array($month_array)),
-
array(array($source_array)),
-
array(array($table_row))
-
);*/
-
//print_r($display_array);
-
$display_array = array($month_array=>array($source_array=>array($table_row)));
-
|