1

I am a newbie in PHP/MySQL and this is my first question on stackoverflow, so please ignore any mistake if I have made any.

I am trying to get records from a table through this query.

$CId = $this->input->post('Child_id'); //child_id is the value from a textfield

$r_detail = ("SELECT *
            FROM `result_details`
            WHERE ResultId
            IN (SELECT Result_Id
            FROM `results`
            WHERE childId = '".$CId." ')  " );

this query is returning an empty $r_detail. However when I query the same statement in PHPMyAdmin in localhost and change "$CID" to a number, I get the desired records.

Any Help will be much appreciated.

1
  • Are you using codeigniter?? Commented Jun 3, 2015 at 7:27

2 Answers 2

1

You have a space in INNER JOIN WHERE: '".$CId." ' should be '".$CId."'.

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

Comments

0
   $r_detail  = ("SELECT *
        FROM `result_details`
        WHERE ResultId
        IN (SELECT Result_Id
        FROM `results`
        WHERE childId = '".$CId." ')  " );

has just string...you need to call some db function to get the data such as in code igniter may be

  $this->db->query($r_detail);

Comments

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.