Welcome Guest, Not a member yet? Register   Sign In
Outputting results from Array?
#11

[eluser]invision[/eluser]
Hmm, I'm still getting errors :'(

My Error:
Code:
A PHP Error was encountered Severity: Notice
Message: Undefined index: roomclass1
Filename: views/public_entry.php
Line Number: 35

View line 35:
Code:
<h2 class="sifr-title">&lt;?php $entries['roomclass1']; ?&gt;</h2>
#12

[eluser]Madmartigan1[/eluser]
According to the data you posted earlier, it should be:

Code:
// In view file
$entries['entries'][0]['roomclass1']

Should return "Premium Buchanan view offers both".

Your array looks overly complicated but I assume you need it that way.

Not to be an ass, but I would really suggest reading up on the basics of arrays if you are having this much trouble. It's worth spending the day on.
#13

[eluser]invision[/eluser]
I agree. I'm hoping to get this working then read the manual some more Smile

I couldn't get:

Code:
// In view file
$entries['entries'][0]['roomclass1']
working for me. It gave me an error:

Code:
A PHP Error was encountered Severity: Notice
Message: Undefined index: entries
Filename: views/public_entry.php
Line Number: 35
#14

[eluser]Madmartigan1[/eluser]
I hope you mean the PHP manual and not the Codeigniter manual Smile

Do this and I try to help once more:

In your view, do a print_r() on the variable. Come back and post the output.
#15

[eluser]invision[/eluser]
Big Grin

When I do print_r($entries) I get the following output:

Code:
Array ( [0] => Array ( [id] => 1 [atitle] => Buchanan View [metakeys] => [metadescr] => [aslug] => buchanan-view [status] => published [body] => This is the body of text here. This is the body of text here. This is the body of text here. This is the body of text here. [address] => 35 Calgary Street, G4 0XG [cost] => From: £94.00 p/w [addressdescr] => Buchanan view is located... [features] => Buchanan view offers a range... [roomclass1] => Premium Buchanan view offers both [roomclass2] => Classic Buchanan view offers a range of [roomclass3] => Basic There are no Basic rooms [atype] => 1 [country] => 0 [city] => 2 [category] => 1 [category_id] => 6 [pubdate] => 2010-12-23 [img] => buchanan-view-1-small.jpg [user_id] => 1 [city_title] => Turin [country_title] => ITA [category_title] => Student Accommodation ) )
#16

[eluser]invision[/eluser]
Success!

print_r($entries['0']['atitle']);
#17

[eluser]invision[/eluser]
Thanks for all your help and patience with this.

Please enjoy the rest of your New Years Day now Big Grin
#18

[eluser]Madmartigan1[/eluser]
OK. You have an array that contains another array.

Try this in the view:

Code:
$entries[0]['roomclass1']
#19

[eluser]invision[/eluser]
Yep, I basically have to make this value: ['0']

It's all sorted now. Thanks again for all your help




Theme © iAndrew 2016 - Forum software by © MyBB