Avihai Posted December 25, 2007 Share Posted December 25, 2007 Hi all, I am new here :-) I am working with joomla and have this code: $sqlb = "SELECT a.id AS eventid" . "\nFROM #__eventlist_dates AS a" . "\nLEFT JOIN #__eventlist_locate AS b ON b.id = a.locid" . "\nLEFT JOIN #__eventlist_categories AS c ON c.id = a.catsid" . "\nWHERE a.published = 1" . "\nAND c.access <= $my->gid" . "\n$tf ".$sc . "\nORDER BY a.dates, a.times" . "\nLIMIT 0, $mcount"; $database->setQuery($sqlb); $rowsb = $database->loadObjectList(); //echo count($rowsb); for ($i=0;$i<count($rowsb);$i++) { $ani=get_object_vars($rowsb[$i]); $ani['eventid']; foreach ($ani as $b) { $anib = array($b); echo $b; } } That prints me the id of the items that are present in the database and all is ok. Problem: I am trying to take each one of the results and insets them separately into a var, but I just don't know how to do that. The ultimate goal is to be able to pass that var to another php script (maybe via cookie? I don't know - need help in that too). Q: Can any one help? // When I write this line I get a full result: print_r($ani); // Thanks, A.O Quote Link to comment https://forums.phpfreaks.com/topic/83131-array-and-db-question/ Share on other sites More sharing options...
shreej21 Posted December 25, 2007 Share Posted December 25, 2007 try below foreach loop foreach ($ani as $b) { $anib[] = $b; echo $b; } print_r($anib); Quote Link to comment https://forums.phpfreaks.com/topic/83131-array-and-db-question/#findComment-422891 Share on other sites More sharing options...
PHP_PhREEEk Posted December 25, 2007 Share Posted December 25, 2007 It's much easier to just pass around $ani, which has all the values you need. Anytime you need to call a $ani element, just use $ani['needed_value'] and there you go... To pass to another script... I'm not familiar with Joomla, but most CMS type apps have a certain set of initialization lines to make a page "start up", which also populates certain important variables and arrays. So, if your custom page uses that same "start up" process, you'll also get the necessary variables right up front. At any rate, you can pass $ani in directly using a variety of methods, or it's created during a start up, initialize the start up. We'd need more information if you can't figure it out from there... PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/83131-array-and-db-question/#findComment-422961 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.