In my MySQL database I have this table which contains multiple artists. They are placed in a field called formated_name and returns strings like for example Lady Gaga, so far so good. What I want to achieve is that it returns ladygaga so I can use it for my url later on. My whole function looks like this:
public function artistname_get($artist_id)
{
$this->load->database();
$sql = "SELECT formated_name FROM artists WHERE artist_id = '".$artist_id."'";
$query = $this->db->query($sql);
$data = $query->result();
if($data) {
$this->response($data, 200);
} else {
$this->response(array('error' => 'Couldn\'t find any artist with that name!'), 404);
}
}
So how can I achieve this?