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..
[code=php]
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,$curre nt_year-1));
}
$array = array("Reviewes " => "systematic_rev iews" , "Summaries" => "evidence_summa ry" , "Care Bundles" => "care_bundl es" , "Best Practice Information Sheets" => "best_practice" );
foreach($array as $source => $source_query) {
$query = "SELECT DISTINCT ID,Title,Author s,Source,Year,D ate,pdfURL,html URL FROM (\n${$source_qu ery}\n) AS `{$source_query }`\n WHERE Date LIKE '$current_year-%$i-%' ORDER BY Date DESC";
$result_array[$source] = mysql_query($qu ery, $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_te xt);
foreach($array as $source => $source_query) {
$result = $result_array[$source];
$num = $num_array[$source];
if($num){
$source_text .= "<p><a href = '#$source'>$sou rce</a></p>";
$source_array = array($source_t ext);
$table_row = array();
$table_row[] = "<table class='pretty'>
<tr valign='bottom' class='header'>
<th>Id</th>
<th><p align='left'>Pu blication Title</p></th>
<th><p align='left'>So urce</p></th>
<th><p align='left'>Au thors</p></th>
<th><p align='left'>Ye ar</p></th>
<th>Date</th>
<th>ViewPDF</th>
<th>ViewHTML</th>
</tr> ";
$alternate_row = false;
while($row = mysql_fetch_ass oc($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($htmlU RL) ? $pdfURL : $htmlURL) : $dsURL;
$table_row[] = "<td><a href = '$title_URL' onclick='window .open('$title_U RL'); return false;'>$Title</a></td>";
$table_row[] = "<td>$Sourc e</td>";
$table_row[] = "<td>$Autho rs</td>";
$table_row[] = "<td>$Year</td>";
$table_row[] = "<td>$Date</td>";
if(is_null($pdf URL)){
$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_ta g('icon_small_p df', 17, 17, NULL, 'icon17p') ?></a></td>";
//<?php
} // end if_else
if (is_null($htmlU RL)) {
$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_UR L '); return false;'><?= generate_img_ta g('icon_small_p df', 17, 17, NULL, 'icon17p') ?></a></td>";
//<?php
} #end if else(is_null($h tmlURL))
$table_row[] = "</tr>";
$alternate_row = !$alternate_row ;
}# end while()
$table_row[] = "</table>";
/*$display_array = array(
"month"=>$month _array,
"source"=>$sour ce_array,
"table"=>$table _row
);
*/
/*$display_array = array(array(arr ay($month_array )),
array(array($so urce_array)),
array(array($ta ble_row))
);*/
//print_r($displa y_array);
$display_array = array($month_ar ray=>array($sou rce_array=>arra y($table_row))) ;
print_r($displa y_array);
}# end if($num)
}#end foreach()
$num_displayed_ months++;
} #end for()
I have used below code to declare my multidimensiona l array..
/*$display_array = array(
"month"=>$month _array,
"source"=>$sour ce_array,
"table"=>$table _row
);
*/
/*$display_array = array(array(arr ay($month_array )),
array(array($so urce_array)),
array(array($ta ble_row))
);*/
//print_r($displa y_array);
$display_array = array($month_ar ray=>array($sou rce_array=>arra y($table_row))) ;
[/code]
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..
[code=php]
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,$curre nt_year-1));
}
$array = array("Reviewes " => "systematic_rev iews" , "Summaries" => "evidence_summa ry" , "Care Bundles" => "care_bundl es" , "Best Practice Information Sheets" => "best_practice" );
foreach($array as $source => $source_query) {
$query = "SELECT DISTINCT ID,Title,Author s,Source,Year,D ate,pdfURL,html URL FROM (\n${$source_qu ery}\n) AS `{$source_query }`\n WHERE Date LIKE '$current_year-%$i-%' ORDER BY Date DESC";
$result_array[$source] = mysql_query($qu ery, $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_te xt);
foreach($array as $source => $source_query) {
$result = $result_array[$source];
$num = $num_array[$source];
if($num){
$source_text .= "<p><a href = '#$source'>$sou rce</a></p>";
$source_array = array($source_t ext);
$table_row = array();
$table_row[] = "<table class='pretty'>
<tr valign='bottom' class='header'>
<th>Id</th>
<th><p align='left'>Pu blication Title</p></th>
<th><p align='left'>So urce</p></th>
<th><p align='left'>Au thors</p></th>
<th><p align='left'>Ye ar</p></th>
<th>Date</th>
<th>ViewPDF</th>
<th>ViewHTML</th>
</tr> ";
$alternate_row = false;
while($row = mysql_fetch_ass oc($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($htmlU RL) ? $pdfURL : $htmlURL) : $dsURL;
$table_row[] = "<td><a href = '$title_URL' onclick='window .open('$title_U RL'); return false;'>$Title</a></td>";
$table_row[] = "<td>$Sourc e</td>";
$table_row[] = "<td>$Autho rs</td>";
$table_row[] = "<td>$Year</td>";
$table_row[] = "<td>$Date</td>";
if(is_null($pdf URL)){
$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_ta g('icon_small_p df', 17, 17, NULL, 'icon17p') ?></a></td>";
//<?php
} // end if_else
if (is_null($htmlU RL)) {
$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_UR L '); return false;'><?= generate_img_ta g('icon_small_p df', 17, 17, NULL, 'icon17p') ?></a></td>";
//<?php
} #end if else(is_null($h tmlURL))
$table_row[] = "</tr>";
$alternate_row = !$alternate_row ;
}# end while()
$table_row[] = "</table>";
/*$display_array = array(
"month"=>$month _array,
"source"=>$sour ce_array,
"table"=>$table _row
);
*/
/*$display_array = array(array(arr ay($month_array )),
array(array($so urce_array)),
array(array($ta ble_row))
);*/
//print_r($displa y_array);
$display_array = array($month_ar ray=>array($sou rce_array=>arra y($table_row))) ;
print_r($displa y_array);
}# end if($num)
}#end foreach()
$num_displayed_ months++;
} #end for()
I have used below code to declare my multidimensiona l array..
/*$display_array = array(
"month"=>$month _array,
"source"=>$sour ce_array,
"table"=>$table _row
);
*/
/*$display_array = array(array(arr ay($month_array )),
array(array($so urce_array)),
array(array($ta ble_row))
);*/
//print_r($displa y_array);
$display_array = array($month_ar ray=>array($sou rce_array=>arra y($table_row))) ;
[/code]
Comment