Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Array to table 09 Apr 2012 15:42 #1951

  • devil
  • devil's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 2
Hi,

i have 3 Tables: events - categories - cache

Every time i create a new event ,i get the categories via json from an external server via Json (curl).

Now i will put the Categories (id,name) to the "categories" table (inside helper).

Anyone have an idea how?


Here the code inside the helper to get the categories:
function enumList($ctrl, $fieldName)
	{
			$url='http://**************';

				$curl = curl_init();
				curl_setopt($curl, CURLOPT_URL, $url);
				curl_setopt($curl, CURLOPT_HEADER, 0);
				curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
				$get = curl_exec($curl) or die('Error.');
				curl_close($curl);

				$data = json_decode($get);
				$cats = $data->data;
               


				//build the select with categorie names
				$lists = array();
				$lists["events"]["kategorie"] = array();

				foreach($cats as $cat){
					if($cat->id==$id) $title = $cat->title;

							$lists["events"]["kategorie"][$cat->id] = array("value" => $cat->id, "text" => $cat->title);
                         
					}
                
		return $lists[$ctrl][$fieldName];
	}

Please Log in or Create an account to join the conversation.

Last edit: by devil.
  • Page:
  • 1
Time to create page: 0.075 seconds

Real time saver and great Component Builder tool ! I have been developing with J-Cook Pro Component Builder for several months now and can say with all honesty that this product/service is second to none. The product is feature rich and is being improved and added to all the time. Do yourself a favor if you need to build a Joomla! Component then you can do no wrong in trying the product. You will save on time and effort while being able to deliver your project on time. J-Cook pro does the hard work for you you then have the freedom to fully customise the end result for your own needs. 

One word: Awesome.
Edwardcox (JED)
         

Get Started