problems with array - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: problems with array (/showthread.php?tid=24924) Pages:
1
2
|
problems with array - El Forum - 11-24-2009 [eluser]dunken[/eluser] Hello. Can some1 tell me what i am doing wrong. I get duplicates in the second array. code: Code: function get_documents($section){ after putting some test data in it, i get this. Code: Array as u can see the mark text has already been written to the first array, why is it in the second as well? thanks for understanding my English problems with array - El Forum - 11-24-2009 [eluser]Bazze[/eluser] And how do you call the get_documents()-function? Do you call it once or twice? problems with array - El Forum - 11-24-2009 [eluser]dunken[/eluser] Code: function documents(){ edit: once problems with array - El Forum - 11-24-2009 [eluser]jedd[/eluser] Please provide your TABLE definition for your documents table - and we'll be able to write a cleaner query that does this in one fell swoop. It looks like you just need a simple LEFT JOIN here. problems with array - El Forum - 11-24-2009 [eluser]dunken[/eluser] id int(7) date int(11) user int(7) header varchar(255) flow varchar(255) section varchar(255) document varchar(255) edit: some of u make such fine tables with _ and |, is there a way to do that without making them myself? problems with array - El Forum - 11-24-2009 [eluser]jedd[/eluser] [quote author="dunken" date="1259108423"] edit: some of u make such fine tables with _ and |, is there a way to do that without making them myself?[/quote] Code: $ mysql problems with array - El Forum - 11-24-2009 [eluser]dunken[/eluser] Code: +----------+--------------+------+-----+---------+----------------+ thx for the tip problems with array - El Forum - 11-24-2009 [eluser]jedd[/eluser] Okay, I think you want something like this - but note this is untested code, so you'll have to play around with it. Code: SELECT Remember to put your LIMIT and WHERE clauses back in. Not sure if you need a DISTINCT with this. problems with array - El Forum - 11-24-2009 [eluser]dunken[/eluser] ok, but I want an answer like my array in the first post (but without the duplicates). I need to send the multidim-array so that i can catch both the arrayname and the content, something like this. Code: foreach($arrFlows as $flowname => $flownames) How do I do that with your sql? I mean, there has to be a simple mistake in my code. problems with array - El Forum - 11-24-2009 [eluser]cahva[/eluser] Yes, there is a simple mistake in your code. You have to clear the $flows array for the next iteration. Now its always adding to the same array. Code: $flows = array(); // add this to clear it |