I'm trying to add an array to the table. Try so

$query="SELECT * FROM letters"; $result=mysqli_query($db,$query) or die("error".mysqli_error($db)); preg_match_all("~[^\s]{1}~u", $replace, $arrayletters); foreach (array_count_values($arrayletters[0]) as $k => $v){ $query="INSERT INTO letters (kkey, vvalue) values ('".$k."', '".$v."')"; $result=mysqli_query($db,$query) or die("error".mysqli_error($db)); } 

But it does not work

  • What kind of mistake it is that does not come out - Naumov
  • It adds to the table. But the records are overwritten. That is, this method itself is not correct - demamon
  • Well, so show the structure of the table in the question? - Naumov
  • the table is called letters. The kkey field in which the letters are stored and the vvalue in which the number of times this letter is stored. There is also a table - site. It stores information about the site. I think to link the site id to assign to each record of the letter for the link. - demamon
  • @demamon If not difficult, execute SHOW CREATE TABLE letters and complete the result with the answer. - cheops

0