Skip to content

Instantly share code, notes, and snippets.

@davidverhage
Created August 24, 2015 20:08
Show Gist options
  • Save davidverhage/7cf7f5c3e0043cf99ab1 to your computer and use it in GitHub Desktop.
Save davidverhage/7cf7f5c3e0043cf99ab1 to your computer and use it in GitHub Desktop.
For legend sake
/**
* 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