I'm trying to write to a person's BD
communication data and I'm not able to resolve it, the data in that communication is Email
, Telefone Empresa
, Celular Empresa
and Ramal
, each of these are registered types in a table called cadTipoComunicacao
and later I try to write that data to a table called cadComunicacao.
I have the information available:
// TIPOS DE COMUNICAÇÃO $IdTipoRamal = 1; $IdTipoTe = 3; $IdTipoCe = 4; $IdTipoEmail = 6; // INFORMAÇÃO $Ramal = 1820; $TelEmpresa = '(44) 3733-8810'; $CelEmpresa = '(44) 99898-8585'; $Email = '[email protected]';
And the following structure for agrupar
information:
$Registros = array ( array($IdTipoRamal,$Ramal), array($IdTipoTe, $TelEmpresa), array($IdTipoCe, $CelEmpresa), array($IdTipoEmail, $Email) );
What am I doing to display the information:
for ($row = 0; $row < 4; $row++) {
echo "<ul>";
for ($col = 0; $col < 2; $col++) {
echo "<li>".$Registros[$row][$col]."</li>";
}
echo "</ul>";
}
The output of this code is this:
TheInsertcodeoftheattemptImadeisthis:
//DADOSDACOMUNICAÇÃO$Registros=array(array($IdTipoRamal,$Ramal),array($IdTipoTe,$TelEmpresa),array($IdTipoCe,$CelEmpresa),array($IdTipoEmail,$Email));//INSERIRfor($row=0;$row<4;$row++){//echo"<ul>";
for ($col = 0; $col < 2; $col++) {
// echo "<li>".$Registros[$row][$col]."</li>";
$crud = $pdo->prepare("INSERT INTO cadComunicacao ( IdPessoa, IdTipo, Informacao ) VALUES (?, ?, ?)");
$crud->bindParam(1, $IdPessoa , PDO::PARAM_INT);
$crud->bindParam(2, $IdTipo , PDO::PARAM_INT);
$crud->bindParam(3, $Informacao , PDO::PARAM_STR);
$retorno = $crud->execute();
}
// echo "</ul>";
}
What I am not able to do is to loop through and write TypeType and Information, in the image the IdType is the first value and the Information is the second.
I can not write everything to the Informacao
field, I need to loop through and write the IdPessoa
, IdTipo
and the 'Information', which in the case above can be multiple lines for Type and Information Id.
The table cadComunicacao, where I am trying to write the information has this structure: