Store array value in angular2 backend php database frontend?

Hello, first of all, sorry if this question has already asked a question? But I'm stuck on this exactly what I want. I am trying to create a rest api for my angular2 frontend. Everything works fine since I was calling rest api and angular2 and starting the database value in a specific table. as

$stmt = $db->prepare("INSERT INTO `create_profile`(`developerType`, `skills`, `level`, `workType`, `message`) VALUES (:developerType, :skills, :level, :workType, :message)");$stmt->bindParam(':developerType', $params->developerType);
      

Run codeHide result


But I am stuck on how to store the value that the array contains in the value location like in my skill sheet there is an array with 2 values, but how can I store it in the database.

I use like this.

$stmt->bindParam(':skills', $data);
      

Run codeHide result


but its not working. I know I missed something, but what I don't know. Please help me

+3


source to share


1 answer


you may try



$data = array();
$skillSet = $params->skills;
foreach($skillSet as $team)
    $data[] = "" . addslashes($team->skillName) . "";

$data = implode("," , $data);

$stmt->bindParam(':skills', $data);
      

Run codeHide result


you need to decouple your array first and after that it can be stored in the database, hope it helps you. :)

+5


source







All Articles