0

I have to insert data from another table,but same database. Can someone help me how to achieve that?

Here is my working code for one table:

Code is taken from http://www.angularcode.com/demo-of-a-simple-crud-restful-php-service-used-with-angularjs-and-mysql/

private function xyz(){ 
    if($this->get_request_method() != "GET"){
            $this->response('',406);
    }
    $id = (int)$this->_request['id'];
    if($id > 0){    
        $query="SELECT distinct t.field1, t.field2, t.field3 FROM table1 t where t.field1=$id";
        $r = $this->mysqli->query($query) or die($this->mysqli->error.__LINE__);
        if($r->num_rows > 0) {
            $result = $r->fetch_assoc();    
            $this->response($this->json($result), 200);
        }
    }
    $this->response('',204);
}
8
  • What part of that is angular? Commented Oct 13, 2014 at 12:57
  • none, corrected it. no angularjs in this code, ofc. Commented Oct 13, 2014 at 12:59
  • Where is the part what you have tried to insert data from one table into another? Commented Oct 13, 2014 at 13:00
  • you can insert data from one table to another using only mysql. no php is needed. Commented Oct 13, 2014 at 13:03
  • Sorry, can you give me an example? Commented Oct 13, 2014 at 13:03

0

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.