I have two tables, table A with id and tasks (description), and another table B with the task fk, quantity, fk, and official. In addition to other columns that is not the case.
In my table in the html (table), I show all the tasks already in thead, and in the results I take the respective quantities of each task.
The problem is that a store can register 5 tasks, and register activities for its employees, however, after a while, it can register another task, only that qd this occurs, my table view in the html breaks. For in my table B there is no data for this new task.
Would anyone have any suggestions on how to solve this problem?
Part of the job quest query:
//tabela A, checo todas as tarefas cadastradas
$consulta2 = $pdo->prepare("SELECT id_tarefa FROM tarefa WHERE id_loja=:id");
$consulta2->bindParam(':id', $id_loja, PDO::PARAM_INT);
if($consulta2->execute()){
if($consulta2->rowCount() > 0){
while($dados_cons2 = $consulta2->fetch(PDO::FETCH_OBJ)){
$id_tarefa2=$dados_cons2->id_tarefa;
//essa seria minha tabela B, checo todas as atividades, que possuem as quantidades da tarefas
$dados3 = $pdo->prepare("SELECT * FROM atividades_diarias as ativ where ativ.id_ativ=:id_ativ and ativ.id_loja=:id_loja and ativ.tipo_atividade=:tipo and ativ.id_tarefa=:id_taf");
$dados3->bindParam(':id_ativ',$id_ativ, PDO::PARAM_INT);
$dados3->bindParam(':id_loja',$id_loja, PDO::PARAM_INT);
$dados3->bindParam(':tipo',$tipo_atividade, PDO::PARAM_STR);
$dados3->bindParam(':id_taf',$id_tarefa2, PDO::PARAM_INT);
$dados3->execute();
while($table3 = $dados3->fetch(PDO::FETCH_OBJ)){
$qtd_tarefa = $table3->qtd_tarefa;
//só que as tarefas novas n tem dados antigos na minha tabela B, ele é inexistente, aí quebra a tabela
if($qtd_tarefa!=null){ //usei null mas n funcionou
echo'<td>'.$qtd_tarefa.'</td>';
}else{
$vazio="";
echo'<td>'.$vazio.'</td>';
}
}
My table in HTMl (example)
Date .... Official Name ... task1 .... task2 ... NOVATAREFA ..... schedule entry
1/6/18 ......... Isadora ............... 2 ................ 3 .. ............ 08:00
Result I need:
Date .... Official Name ... task1 .... task2 ... NOVATAREFA ..... schedule entry
1/6/18 ......... Isadora .............. 2 ............. 3 ...... ............... EMPTY ................. 08:00
Note that the new job is taken to the value of the next column, which should be empty, as there is no historical data about it.
Does anyone know how I can check to see if my task exists in table B, and if n is null in table view in html? I have tried several alternatives, including inner join.
Thank you!