laravel - Populate select element -


i want populate <select> element using results categories table. in order use following code.

$catlist = categories::where('type','=',$content_type)            ->get(array('id','name'))->toarray();  

the result structure array of rows.

array   0 =>     array       'id' => int 1       'name' => string 'article'    1 =>     array      'id' => int 2      'name' => string 'news'  

a foreach statement surely solve problem i'm looking better solution.

you use lists(string $column [, string $key ]) method this, found under "retrieving list of column values" in documentation...

$catlist = category::where('type', $content_type)->lists('name'); 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -