I want to alter column name dynamic in existing table using php and mysql

Viewed 15

I know the reason why the error is coming I

 $newarr = [];
  if(count($_POST['dynamic_field'])){
    foreach($_POST['dynamic_field'] as $key=>$value)
     {
      $this->db->query('ALTER TABLE tbl_order ADD '.$key.' varchar(255)');
      $newarr[$key] =json_encode($value);
     } 
  }

just want to know to logic.

0 Answers
Related