how to search for more than one column in php

Asked

Viewed 71 times

-1

I’m doing a researcher for a client’s website, I did the form code and the research. and showed the result.

my table and so on:

NAME.BIRTH DATE.IDADE.DEATH DATE.QUADRA.TOMB.DRAWER

in the case at the time the result and only the name, more precise than the other columns also, when I put the name of the person, appears the other data of the row

php search code:

<?php
    $servidor = "localhost";
    $usuario = "root";
    $senha = " SENHA OCULTA";
    $database = "cemiterio";
    //Criar a conexao
    $conn = mysqli_connect($servidor, $usuario, $senha, $database);

    $pesquisar = $_POST['pesquisar'];
    $sql = "SELECT * FROM `jazigos` WHERE `NOME` LIKE '%{$pesquisar}%' LIMIT 25";
    $resultado_cemiterio = mysqli_query ($conn,$sql);

     while($rows_sql = mysqli_fetch_array($resultado_cemiterio, MYSQLI_ASSOC)){
        echo "Resultado da Pesquisa:". $rows_sql["NOME"]  ."<br>";


    }
?>

1 answer

0

Add the other columns in your while as well... you just specified the column of the name, so only the column name is appearing:

  while($rows_sql = mysqli_fetch_array($resultado_cemiterio, MYSQLI_ASSOC)){
        echo "Resultado da Pesquisa:". $rows_sql["NOME"]  ."<br>";
        echo "Resultado da Pesquisa:". $rows_sql["DATA DE NASCIMENTO"]  ."<br>";
        echo "Resultado da Pesquisa:". $rows_sql["IDADE"]  ."<br>";
        echo "Resultado da Pesquisa:". $rows_sql["DATA DE FALECIMENTO"]  ."<br>";
        echo "Resultado da Pesquisa:". $rows_sql["QUADRA"]  ."<br>";
        echo "Resultado da Pesquisa:". $rows_sql["JAZIGO"]  ."<br>";
        echo "Resultado da Pesquisa:". $rows_sql["GAVETA"]  ."<br>";
        echo "------------------------------------------------<br>";

    }
  • it gave error: Notice: Undefined index: DATA_DE_NASCIMENTO in C: wamp64 www Cemiterio search.php on line 17 and this too: Notice: Undefined index: DATA_DE_FALECIMENTO in C: wamp64 www Cemiterio search.php on line 19

  • What is the name of the columns in the bank?

  • 1 ID 2 NAME 3 BIRTH DATE 4 AGE 5 DEATH DATE 6 QUADRA 7 TOMB 8 Drawer plus colona id does not need to appear

  • DATE OF BIRTH is with same space?

  • date of birth and death and space

  • So where was DATA_DE_NASCIMENTO puts BIRTH DATE and DATA_DE_FALECIMENTO exchange for DEATH DATE

  • be working, what joy which command for me to separate the results

  • What do you mean, "separate the results?"

  • came out like this: Name of the Deceased:MARIA ODETE SOUSA Date of Birth:20/1/1941* Age: Date of Death:26/12/2012+ Square:3 Jazigo:936 Drawer:1 Name of the Deceased:MARIA ODETE SOUSA Date of Birth:20/1/1941* Age: Date of Death:26/12/2012+ Court:3 Tomb:936 Drawer:1

  • ai wanted to format to separate type like this: Name of the Deceased:MARIA ODETE SOUSA Date of Birth:20/1/1941* Age: Date of Death:26/12/2012+ Square:3 Tomb:936 Drawer:1 --------------------------------------------------------------------------- Name of Deceased:MARIA ODETE SOUSA Date of Birth:20/1/1941* Age: Date of Death:26/12/2012+ Court:3 Tomb:936 Drawer:1

  • I edited the question and added this.. if ok please mark the answer as correct

Show 6 more comments

Browser other questions tagged

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