473,320 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Multidimensional array declaration and dispaly

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..
Expand|Select|Wrap|Line Numbers
  1. for($i=$current_month; ($num_displayed_months < 5) && ($i >= 0); $i--) {
  2.     $result_array = array();
  3.     $num_array = array();
  4.     $num_total = 0;
  5.     if($i == 0){
  6.        $i = $current_month;
  7.      $current_year = date("Y",mktime(0,0,0,$current_month,1,$current_year-1));
  8.     }
  9.     $array = array("Reviewes" => "systematic_reviews" , "Summaries" => "evidence_summary" , "Care Bundles" => "care_bundles" , "Best Practice Information Sheets" => "best_practice");
  10.     foreach($array as $source => $source_query) {
  11.  
  12.         $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";
  13.         $result_array[$source] = mysql_query($query, $dblink) or die(mysql_error() );
  14.         $num_array[$source] = mysql_num_rows($result_array[$source]);
  15.     }
  16.  
  17.     foreach ($num_array as $n) {
  18.         $num_total += $n;
  19.     }
  20.  
  21.     if ($num_total == 0) continue;
  22.  
  23.     $name = date("F",mktime(0,0,0,$i));
  24.       $month_text .= "<p><a href ='#$name'>New updates in $name $current_year</a></p>";
  25.       $month_array = array($month_text);
  26.  
  27.     foreach($array as $source => $source_query) {
  28.         $result = $result_array[$source];
  29.         $num = $num_array[$source];
  30.  
  31.         if($num){
  32.          $source_text .= "<p><a href = '#$source'>$source</a></p>";
  33.          $source_array = array($source_text);
  34.  
  35.  
  36.            $table_row = array();
  37.             $table_row[] = "<table class='pretty'>
  38.                 <tr  valign='bottom' class='header'>
  39.                     <th>Id</th>
  40.                     <th><p align='left'>Publication Title</p></th>
  41.                     <th><p align='left'>Source</p></th>
  42.                     <th><p align='left'>Authors</p></th>
  43.                     <th><p align='left'>Year</p></th>
  44.                     <th>Date</th>
  45.                     <th>ViewPDF</th>
  46.                     <th>ViewHTML</th> 
  47.                 </tr> ";
  48.                 $alternate_row = false;
  49.                 while($row = mysql_fetch_assoc($result)){
  50.                     extract($row);
  51.                     //output table
  52.                     $trclass = ($alternate_row == true)? "even" : "odd" ;
  53.                                         $table_row[] = "<tr class = $trclass>";
  54.  
  55.                     $table_row[] = "<td>$ID</td>";
  56.                         $title_URL = $ismember  ? (is_null($htmlURL) ? $pdfURL : $htmlURL) : $dsURL; 
  57.  
  58.                     $table_row[] = "<td><a href = '$title_URL' onclick='window.open('$title_URL'); return false;'>$Title</a></td>";
  59.                                             $table_row[] = "<td>$Source</td>";
  60.  
  61.                     $table_row[] = "<td>$Authors</td>";    
  62.  
  63.                     $table_row[] = "<td>$Year</td>";    
  64.  
  65.                     $table_row[] = "<td>$Date</td>";
  66.                         if(is_null($pdfURL)){
  67.                                                     $table_row[] = "<td align='center'>N/A</td>";
  68.                         }
  69.                         else{
  70.                             $pdf_URL = $ismember ? $pdfURL : $dsURL; 
  71.  
  72.                        $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>";
  73.  
  74.                             //<?php 
  75.                         } // end if_else    
  76.                         if (is_null($htmlURL)) {
  77.                                                         $table_row[] = "<td align='center'>N/A</td>";
  78.                         }
  79.                         else {
  80.                             $html_URL = $ismember ? $htmlURL : $dsURL; 
  81.  
  82.                                                 $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>";
  83.  
  84.                          //<?php
  85.                         } #end if else(is_null($htmlURL))
  86.                                         $table_row[] = "</tr>";
  87.                     $alternate_row = !$alternate_row;
  88.                 }# end while()
  89.  
  90.                         $table_row[] = "</table>";
  91.                         /*$display_array = array(
  92.                                     "month"=>$month_array,
  93.                                     "source"=>$source_array,
  94.                                     "table"=>$table_row
  95.                                    ); 
  96.                                   */
  97.             /*$display_array = array(array(array($month_array)),
  98.                                    array(array($source_array)),
  99.                                    array(array($table_row))
  100.                                    );*/
  101.                         //print_r($display_array);
  102.             $display_array = array($month_array=>array($source_array=>array($table_row)));
  103.              print_r($display_array);
  104.         }# end if($num)
  105.     }#end  foreach()
  106.     $num_displayed_months++;
  107. } #end for()
  108.  
  109. I have used below code to declare my multidimensional array..
  110. /*$display_array = array(
  111.                                     "month"=>$month_array,
  112.                                     "source"=>$source_array,
  113.                                     "table"=>$table_row
  114.                                    ); 
  115.                                   */
  116.             /*$display_array = array(array(array($month_array)),
  117.                                    array(array($source_array)),
  118.                                    array(array($table_row))
  119.                                    );*/
  120.                         //print_r($display_array);
  121.             $display_array = array($month_array=>array($source_array=>array($table_row)));
  122.  
Dec 11 '07 #1
1 1735
my declaration is not working properly...

Need help to delcare multidimensionaly array

Thanks..
Dec 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
3
by: SpotNet | last post by:
Hi NewsGroup; Trying to construct a Multidimensional (2D more specifically) populated from an OleDbDataReader. Reason I'm using an ArrayList is I do not know the size of the first dimension...
21
by: utab | last post by:
Hi there, Is there a way to convert a double value to a string. I know that there is fcvt() but I think this function is not a part of the standard library. I want sth from the standard if...
21
by: vito | last post by:
how to achieve that? it seems php doesn't support it well for a C programmer? i hope to use something like: a; a; a;
4
by: Gregory.A.Book | last post by:
I'm working with displaying and manipulating very large image sets. The program handles anything from 2D images to 4D RGB volumes in a time-series. I've been using dynamically allocated arrays to...
10
by: shadab | last post by:
I am having big problem retrieving data assgined to dynamic 2-d array . i am calculating and saving data in to dynamic 2-d array. but when i retrieve them, it doesnt give correct values. you...
1
by: nivaz | last post by:
hai friends plz help me in this matter, i want to know really about the declaration of multidimensional array in VB. plz do reply
2
by: ...vagrahb | last post by:
I am having accessing individual rows from a multidimensional array pass to a function as reference CODE: function Declaration int Part_Buffer(char (*buffer),int Low, int High)
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.