searching text in database

Asked

Viewed 39 times

0

hello, I am developing a Faq system and I use MVC architecture, I created a search structure within my model, and I passed the parameters within the control but when listing inside the view does not appear. someone could give me a help.

Faq.php template

<?php

function listarPerguntas($mysqli)
{

    $sqlAjudaFaq = $mysqli->query("SELECT pergunta_FAQ, resposta_FAQ FROM ajuda_FAQ");


    while ($lAjudaFaq = $sqlAjudaFaq->fetch_assoc()) {


        $pergunta = $lAjudaFaq['pergunta_FAQ'];
        $resposta = $lAjudaFaq['resposta_FAQ'];

        $faq[] = array(
            "pergunta" => $pergunta,
            "resposta" => $resposta

        );
    };

    return array(
        "faq" => $faq
    );
}

?>

php controller.

public function ajuda(Application $app)
    {
if ($dominiosPermitidos) {
            include("../includes/ds8.php");
            include("../src/App/ajuda.php");
            include("../src/App/relatorios.php");

            $dadosPergunta = listarPerguntas($mysqli, $app);

        } else {
            return $app['twig']->render(
                'ajuda.html',
                array(

                    'faq' => $dadosPergunta
                )

            );
        }
}

paginaFaq.html

<div class="row">
            <div class="col-lg-12">
                <div class="menu-faq">
                    <h3>Como podemos lhe ajudar?</h3>
                    <div class="submit-line">
                        <input id="#" type="text" class="form-control input-faq" placeholder="Digite palavras-chaves para pesquisar" />
                        <button class="submit-lente" type="submit">
              <i class="fa fa-search"></i>
            </button>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                {%for perguntas-faq in pergunta%}
                <div class="boxFaq">

                    <a class="btn btn-faq accordion" type="button" data-toggle="collapse" data-target="#collapse_resposta_faq" aria-expanded="true">
                    {{pergunta-faq.pergunta}}
                    </a>

                </div>
                {%endfor%}
            </div>

            <div class="col-sm-12">
                {%for respostas-faq in resposta%}
                <div id="collapse_resposta_faq" class="collapse">
                    {{resposta-faq.resposta}}
                    <div class="card-body">

                    </div>
                </div>
                {%endfor%}
            </div>
        </div>

1 answer

0


my doubt has been resolved.

prolema was a little more focused on my own logic.

modelofaq.php

function listarPerguntas($mysqli)
{
    $faq = array();
    $sqlAjudaFaq = $mysqli->query("SELECT id_FAQ AS id, pergunta_FAQ AS pergunta, resposta_FAQ AS resposta FROM ajuda_FAQ");


if($sqlAjudaFaq->num_rows !=0){
 while ($lAjudaFaq = $sqlAjudaFaq->fetch_assoc()) {
        $faq[] = $lAjudaFaq;

    };

}

    return $faq;
}

appconrtoller.php

if ($dominiosPermitidos) {
            include("../includes/ds8.php");
            include("../src/App/ajuda.php");

            $dadosPergunta = listarPerguntas($mysqli);

            $dadosPesquisa = pesquisaFaq($mysqli);

            return $app['twig']->render('ajuda.html',array(
                    'faq' => $dadosPergunta,
                )

            );
        } 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.