Array priting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ashrafy84
Forum Newbie
Posts: 9
Joined: Tue Dec 23, 2008 4:29 am

Array priting

Post by ashrafy84 »

Hi everybody
I have two array in which one array has a count of 10 and another array with the count of 3. By using these arrays i am trying to print value of one array in the table using php code.

That is, it should create its should create 10 column, but only two values should be printed.

please help me with code.

Below is the code i have tried

Code: Select all

<table cellpadding="0" cellspacing="0" class="list" border="1">
					<tr>
						<td width="10%">Total</td>
						<?php for($i=0;$i<count($BudgetHead);$i++) {
								for($a=0;$a<count($Year_Charges);$a++){	
						?>
						<td width="10%"><?php echo $Year_Charges[$a]["BudgetTotal"]; ?></td>
						<?php  } } ?>
					</tr>
				</table>
$BudgetHeas is an array with the count of 10. The array is
[text]Array
(
[0] => Array
(
[0] => 1
[Ident] => 1
[1] => 15010801
[ProjectCode] => 15010801
[2] => 00
[BudgetHead] => 00
[3] => 100000
[Amount] => 100000
[4] => Advances
[BudgetName] => Advances
)

[1] => Array
(
[0] => 2
[Ident] => 2
[1] => 15010801
[ProjectCode] => 15010801
[2] => 01
[BudgetHead] => 01
[3] => 50000
[Amount] => 50000
[4] => Advisory Committee
[BudgetName] => Advisory Committee
)

[2] => Array
(
[0] => 3
[Ident] => 3
[1] => 15010801
[ProjectCode] => 15010801
[2] => 04
[BudgetHead] => 04
[3] => 50000
[Amount] => 50000
[4] => Books & Travel
[BudgetName] => Books & Travel
)

[3] => Array
(
[0] => 4
[Ident] => 4
[1] => 15010801
[ProjectCode] => 15010801
[2] => 05
[BudgetHead] => 05
[3] => 100000
[Amount] => 100000
[4] => Books and Journals/Periodicals
[BudgetName] => Books and Journals/Periodicals
)

[4] => Array
(
[0] => 5
[Ident] => 5
[1] => 15010801
[ProjectCode] => 15010801
[2] => 09
[BudgetHead] => 09
[3] => 50000
[Amount] => 50000
[4] => Consumables/Supplies
[BudgetName] => Consumables/Supplies
)

[5] => Array
(
[0] => 6
[Ident] => 6
[1] => 15010801
[ProjectCode] => 15010801
[2] => 10
[BudgetHead] => 10
[3] => 50000
[Amount] => 50000
[4] => Consumables & Glasswares
[BudgetName] => Consumables & Glasswares
)

[6] => Array
(
[0] => 7
[Ident] => 7
[1] => 15010801
[ProjectCode] => 15010801
[2] => 15
[BudgetHead] => 15
[3] => 100000
[Amount] => 100000
[4] => Equipment(Major)
[BudgetName] => Equipment(Major)
)

[7] => Array
(
[0] => 8
[Ident] => 8
[1] => 15010801
[ProjectCode] => 15010801
[2] => 18
[BudgetHead] => 18
[3] => 100000
[Amount] => 100000
[4] => Fellowship
[BudgetName] => Fellowship
)

[8] => Array
(
[0] => 9
[Ident] => 9
[1] => 15010801
[ProjectCode] => 15010801
[2] => 19
[BudgetHead] => 19
[3] => 100000
[Amount] => 100000
[4] => Guest Faculty/Lecturer
[BudgetName] => Guest Faculty/Lecturer
)

[9] => Array
(
[0] => 10
[Ident] => 10
[1] => 15010801
[ProjectCode] => 15010801
[2] => 22
[BudgetHead] => 22
[3] => 100000
[Amount] => 100000
[4] => Infrastructure Facility
[BudgetName] => Infrastructure Facility
)

[10] => Array
(
[0] => 11
[Ident] => 11
[1] => 15010801
[ProjectCode] => 15010801
[2] => 24
[BudgetHead] => 24
[3] => 200000
[Amount] => 200000
[4] => Maintenance of Equipments
[BudgetName] => Maintenance of Equipments
)

)


$Year_Charges is an array with the count of 3. The array is
Array
(
[0] => Array
(
[BudgetTotal] => 10000
[0] => Array
(
[0] => 10000
[Amount1] => 10000
[1] => 0
[Amount2] => 0
[2] => 0
[Amount3] => 0
[3] => 0
[Amount4] => 0
[4] => 2010-10-04
[VoucherDate] => 2010-10-04
[5] => 00
[BudgetHead] => 00
[Total] => 10000
)

)

[1] => Array
(
[BudgetTotal] => 50000
[0] => Array
(
[0] => 50000
[Amount1] => 50000
[1] => 0
[Amount2] => 0
[2] => 0
[Amount3] => 0
[3] => 0
[Amount4] => 0
[4] => 2010-10-07
[VoucherDate] => 2010-10-07
[5] => 15
[BudgetHead] => 15
[Total] => 50000
)

)

[2] => Array
(
[BudgetTotal] => 10000
[0] => Array
(
[0] => 10000
[Amount1] => 10000
[1] => 0
[Amount2] => 0
[2] => 0
[Amount3] => 0
[3] => 0
[Amount4] => 0
[4] => 2010-10-15
[VoucherDate] => 2010-10-15
[5] => 19
[BudgetHead] => 19
[Total] => 10000
)

)

)[/text]





scottayy wrote:Please use syntax tags when posting code
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Array priting

Post by requinix »

A number of things you've said are confusing.

What output are you trying to create?
Post Reply