1
Guys, good night. It is difficult to display the values of an array on the front end. In the backend it appears but on the front it does not.
My service task class where is the function that returns the array:
public function procurar(){
global $procura;
$comando = $this->conexao->prepare("select tarefa, id_status from tb_tarefas where tarefa like :nome");
$comando->bindValue(':nome', "%{$procura}%");
$comando->execute();
$inf = $comando->fetchAll(PDO::FETCH_OBJ);
print_r($inf);
}
Here is the part of the code responsible for giving command in the bank in the task class :
elseif($acao == 'procurar'){
$tarefa = new Tarefa();
$conexao = new Conexao();
$procura = isset($_POST['procura']) ? $_POST['procura'] : "";
$tarefaService = new TarefaService($conexao, $tarefa);
$retorno = $tarefaService->procurar();
header('location: buscar_tarefas.php?resultado=1');
}
And then there at the front-end I opened the php block and had written the $return variable. I also gave a require Once to call the task classController:
<?php
global $retorno;
print_r($retorno);
?>
Help me please, guys
I did what you said but it still wasn’t. Could you take a look at the project ? If this isn’t too uncomfortable for you, follow the link on github. The project is in two repositories. github.com/gabrieltec97/Projeto-Help-Desk.git github.com/gabrieltec97/app_lista_tarefas.git
– gabrieltec97
In your code you’re still print_r($inf);, switch to Return $inf and try again. Commit too.
– Paulo Victor
And on your Github also I couldn’t find where you want to display the result
– Paulo Victor
It’s busy there, brother. I want to show there in the file search tasks where I left a comment there. I’m trying to implement a search on that system, now just need to display on screen. Take a look there please
– gabrieltec97
Remove the
header('location: buscar_tarefas.php?resultado=1');
taskController.php:141– Paulo Victor
so brother, if I remove it, it will not display on that page. I want the content to be displayed on this page called lookup
– gabrieltec97
Friend, this is not how you pass data through php pages. The header just redirects, and from what I’ve seen you don’t need it because the.php query has a require of it. Remove and make the "query" through the page search_tasks.php, it would look like this: search_tasks.php? acao=search
– Paulo Victor
Po I’m not understanding the way you’re talking bro, you can change the code there on github and save, if you can’t, you can give me the code here?
– gabrieltec97
I told you, just remove the header(); and make the request by the url search_tasks instead of doing it in taskController
– Paulo Victor
It worked, brother. Thank you so much for your help and patience in helping me. Thanks a lot! tmj
– gabrieltec97