javascript - PHP-Insert Query Result into another Query Statement -


i want run these 3 queries together. how fetch case_id 2nd query insert 3rd query's case_id ?

$query = "insert `case`(`informant_userid`,`casename`,`casetime`) values ('" . $informant_userid . "','" . $casename . "',now())"; $query = "select `case_id` `case` order `case_id` desc limit 1 "; $query = "insert picture (case_pic,case_id) values ('" .addslashes($imagefile). "','" .$case_id"')" ; 

i assume caseid auto-increment column. use last_insert_id() value assigned in recent insert.

$query = "insert `case`(`informant_userid`,`casename`,`casetime`) values ('" . $informant_userid . "','" . $casename . "',now())"; // execute $query $query = "insert picture (case_pic,case_id) values ('" .addslashes($imagefile). "', last_insert_id())" ; // execute $query 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -