I have this query,
$cellId = $db->insert_multiple_data("INSERT INTO tbl_attendance", array('tbl_worksheets_id','tbl_students_id','status','class_dt'), $values_array); Where $values_array is,
$values_array[] = array($id1,$id2,$status,$datetime); It is in the for loop.
Here is now my insert_multiple_data(),
public function insert_multiple_data($sql,$fields,$values_array){ $set = ''; $str = ""; $comma_separated2 = implode(",", $fields); foreach($values_array as $values){ $comma_separated = implode("','", $values); $comma_separated = "'".$comma_separated."'"; $str = $str."(".$comma_separated."),"; } $sql = $sql."(".$comma_separated2.") VALUES ".rtrim($str, ","); $stm = $this->conn->prepare($sql); $stm->execute(); return $this->conn->lastInsertId(); } So these codes above are working. What I need is to make the status an id, how can I select the id of the status(string) from the database? then insert with the query above?