0

I am trying to get the details of a persons based on the user input age (Integer). Now my query always returns null Array() whenever I execute the below code. I haven't specified the $postdata array. You can see I have used $postdata['ageto'] and $postdata['agefrom'] are used in calculating $agefrom and $ageto

        $now = new DateTime();

    //Converting _POST age to Date
    $agefrom = date("Y-m-d",strtotime($now->format("Y")-$postdata['ageto'].'-'.$now->format("m").'-'.$now->format("d")));
    $ageto = date("Y-m-d",strtotime($now->format("Y")-$postdata['agefrom'].'-'.$now->format("m").'-'.$now->format("d")));

    $this->db->select('uacc_id, uacc_username, name, dob, city, education');
    $this->db->from('user_accounts as a');
    $this->db->join('personal as b','a.uacc_id = b.pruserid','INNER');
    $this->db->join('profession as c','a.uacc_id = c.puserid','INNER');
    $this->db->join('location as d','a.uacc_id = d.luserid','INNER');
    $this->db->where('dob >= ',$agefrom);
    $this->db->where('dob <= ',$ageto);
    $this->db->limit(10, $offset);
    $query = $this->db->get();
    return $query->result();

I have suspected that my input post is not fetching the data properly. So I have replaced it with my simple query select * from... where dob >.... and it worked well. So there is no problem with _POST variables. I am not sure what I am doing wrong. Can some one help me.

2
  • 1
    I think you can check your sql command. You can look the site. stackoverflow.com/questions/6142099/… Commented Dec 11, 2013 at 1:35
  • Thanks Lighter.. I got a clue now. Its problem with the POST DATA Commented Dec 11, 2013 at 2:16

2 Answers 2

2

I think you have to specify to which table DOB belongs like a.dob. Sorry for the post but I could not comment. Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

0

The select field should add the table name

$this->db->select('a.uacc_id, a.uacc_username, a.name....); // example

and your where add table name too.

$this->db->where('b.dod >= ', $agefrom); // example

or you can output the sql command.

You can look here

1 Comment

Adding the object name to column doesn't found difference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.