Created
August 24, 2015 20:08
-
-
Save davidverhage/7cf7f5c3e0043cf99ab1 to your computer and use it in GitHub Desktop.
For legend sake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Codeigniter Based | |
* | |
*/ | |
function get_selections($table, $id = 'id', $column = 'name') | |
{ | |
$alert=''; | |
$value= "select * from {$table}"; | |
$result= $this->db->query($value); | |
$count= $result->num_rows(); | |
if(!$count || $count < 1) | |
{ | |
alert.="<select id='null' name='null'><option value='null'>No selection available</option>"; | |
} | |
else | |
{ | |
$alert.="<select class='form-control' name='get_selections'><option value=''>select</option>"; | |
foreach($result->result_array() as $row) | |
{ | |
$alert.="<option value='$row[{$id}]'>$row[{$column}]</option>"; | |
} | |
$alert.="</select>"; | |
} | |
return $alert; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment