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

(This post was last modified: 11-12-2019, 03:49 AM by Chivinsdev.)

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
Reply


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



Theme © iAndrew 2016 - Forum software by © MyBB