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);
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
dermansi
  • 1
  • 2

0 Answers0