Welcome Guest, Not a member yet? Register   Sign In
help me write this mysql query in codeigniter
#6

(11-12-2019, 03:12 AM)Chivinsdev Wrote: Try this one I hope it will help you get what you are looking for.

in your controller.

Either you autoload the database in autoload file or you load it to the controller straight by

PHP Code:
$this->load->database(); // within the controller but I prefer autoload 

in your model just continue with

PHP Code:
public function searchListing($data$location) {
    $q $this->db->select('*, ABS( post_code - '.$location.') AS distance')
         ->from('list_data')
         ->like('business_name'$data)
         ->order_by('distance')
         ->limit(6)
         ->get()
         ->result();
    return $q;


I used the chaining method which is the shorter method. So try it I hope it will help you.
If you are facing more problem and confused let me know either you private message me or drop your problem here. I am here to help

Hi @Chivinsdev, your code works, thank you so much, I've been looking for the solution the whole day. Thanks again
Reply


Messages In This Thread
RE: help me write this mysql query in codeigniter - by acebay - 11-12-2019, 04:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB