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.122 seconds

Les générateurs de code je les connais presque tous pour les avoir essorés en long en large et en travers ... mais celui ci c'est vraiment un outil formidable de simplicité et d'efficacité !
Marc. (liubov - Forum)

Get Started