Welcome, Guest
Username: Password: Remember me

TOPIC: Array to table

Array to table 09 Apr 2012 15:42 #1951

  • devil
  • devil's Avatar
  • Offline
  • New Member
  • Posts: 15
  • Thank you received: 2
  • Karma: 1
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];
	}
Last Edit: 09 Apr 2012 15:46 by devil.
The administrator has disabled public write access.
Time to create page: 0.077 seconds

Get Started