0
I’m trying to create a code covers send messages between users of a system in php, the problem and I can send the message from one user to another but wish it was possible to send to all users, or else to more than one , the same message without having to rewrite.
I created a checkbox field but I’m not able to treat this field, with php
I’m using codeigniter, from what I understand it will give me post a Boolean, true or false
seems easy, just check with if and false or true and register.
but then as I create a loop, to go through the users, I’m a little lost in this question, someone can give me a help there?
THIS IS THE CHECKBOX
<?php
echo form_label("Enviar a todos os usuarios", "newsletter");
$data = array(
'name' => 'envia_todos',
'id' => 'envia_todos',
'value' => 'accept',
'checked' => FALSE,
'style' => 'margin:10px',
);
echo form_checkbox($data);
?>
HERE IS THE CODE THAT TRIES TO CREATE THE LOOP AND SEND IT TO THE BANK
$this->load->model("Buscas_model");
$retorno =array(
"usuarios" => $this->Buscas_model->enconta_todos_usuarios(),
);
foreach($retorno['usuarios'] as $usuario){
$i = 0;
$mensagem['destinatario_id'][$i] = $usuario;
$id_mensagem = $this->Cadastros_model->mensagem($mensagem);
$i++;
}
Before arriving at this function the code checks whether Boolean and true or false to call this function.
Yes truth had not seen that I was restarting the $i to 0 inside the loop that trip, and the post I’m doing in another part of the code that I didn’t post, but for now it’s not working yet, but I’m stirring, if anyone finds any more problem!!
– Eduardo