Array problem in view |
[eluser]webscriptz.be[/eluser]
Hi, I'm writing a system for a webhoster and it needs a language system from the database so i made my db(mysql) and have everything. Ci retrieves it and puts it into the view as an array. model settings.php Code: <?php controller frontpage.php Code: <?php view Code: <p>$data variable</p> I was hoping i could do the following thing in CI: $lang[id]["diffenrent things here"]; because i need them in a template. So anybody any idea? And don't tell me CI language helper is easier to use because i need it to be really agile and adding languages on the fly through an interface.
[eluser]TheFuzzy0ne[/eluser]
Assuming id is the ID of the language, why are you loading all of your languages at once, instead of just loading the language you need? EDIT: I take that back. I was a bit confused by your code.
[eluser]TheFuzzy0ne[/eluser]
I think I understand the question, and I think this is your answer: Code: foreach ($Q->result_array() as $row){ I'd also suggest you use a helper for selecting the key you want, otherwise you will find you have to use isset() a lot or you may end up with warnings. Also, I noticed that your original version of my code above attempts to access an object, when the result is an array.
[eluser]webscriptz.be[/eluser]
I select all the values from "langv" where foreign key lang_id is selected from "langs" and only the one where status is 1. as for the code: I'don't think it's the solution,(sorry), basically I want to do something like smarty does with smarty->assign() so that I can easily take them in the tpl my langv is id - name and value and I was thinking of parsing for each name, the same variable with the value in it.
[eluser]TheFuzzy0ne[/eluser]
Why not use smarty? http://devcha.blogspot.com/2007/12/smart...-code.html
[eluser]webscriptz.be[/eluser]
I like the CI system and smarty irritates me.
[eluser]webscriptz.be[/eluser]
after trying I gave up on smarty but I tried your solution a last time and it works fine now so Thank you! |
Welcome Guest, Not a member yet? Register Sign In |