473,789 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multidimensiona l array declaration and dispaly

8 New Member
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 1753
shailajaAdiga
8 New Member
my declaration is not working properly...

Need help to delcare multidimensiona ly array

Thanks..
Dec 11 '07 #2

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

Similar topics

9
6674
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 function (which was translated from Fortran code), among other heinous and numerous declarations, is this bit: static float bbuff; static int bkey; static int buse;
3
13719
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 (being rows), here's my final attempt below; System.Collections.ArrayList GetDataMatrix = New System.Collections.ArrayList; //Let's just say 10, 3 Keeping it brief and simple excuse the syntax,
21
4201
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 possible. The thing I am trying to do is to convert a double value to a string with 8 elements. 8 is fixed because of the files I work with. I will change this 8 character string with the one(8 character string) already in the file and so on. But I...
21
22931
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
5532
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 accomplish this, but having recently added the ability to load and display 4D data, I've run into some significant performance issues. For a dataset of size 256x176x176x1, it takes about 30 seconds to allocate the array. Loading the data into...
10
1797
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 can run following code in C compiler and see the difference follwoing is my code, please have a look and please reply to sanwa001@fiu.edu
1
1155
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
2294
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
4503
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 function: x = new int;
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10121
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5404
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5539
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4076
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2898
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.