Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
filter table or liste view of data base using php or js

I have a listeview ( table )that shows data of my database , i want to add filter or search box which helps the user to filter the table ( search his name or his infos make other values invisible ) .. I am a beginner in php and js , could you help me or give any solution i can use it ? thankyou

this is my php code(table):

 <?php



$sql="select * from  association  ORDER BY  id ASC"; 
 $result=mysqli_query($con,$sql); 
 if($result){ 

    $num = 1;


    while($ass = mysqli_fetch_array($result)){
       
      $idAss=$ass['idAss'];
      $nom=$ass['nom'];
      $typeActivite=$ass['typeActivite'];
      $location=$ass['location'];
      $adresse=$ass['adresse'];
      $Admin=$ass['Admin'];
$numTel=$ass['numTel'];
$email=$ass['email'];

 echo ' 

                <tr>
                  <th scope="row">'.$num++.'</th>
        
                  <td>'.$idAss.'</td>
                  <td>'.$nom.'</td>
                  <td>'.$typeActivite.'</td>
                  <td>'.$location.'</td>
                  <td>'.$adresse.'</td>
                  <td>'.$Admin.'</td>
                  <td>'.$numTel.'</td>
                  <td>'.$email.'</td>
                
                
                  <td><button class="btn btn-primary">
                  <i class="fa fa-pencil" aria-hidden="true"></i>
                  <a href="update.php?updateid='.$idAss.'" class="text-light">تعديل</a>
                  </button>
                  </td>
                
                  <td> <button class="btn" >
                  <i class="fa fa-trash-o" aria-hidden="true" red-color></i>
                 
                   <a href="deleteAss.php?deleteid='.$idAss.'" class="text-light">حذف</a>
                   </button>
                   </td>
                 

                 
                 
                </tr>
        ';
   }     }
?>

and here is my table: click to see the table

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is just an example that will search by a given name, you will need to perfect it and ensure you're safe against SQL Injection.

Create the form in an HTML file, for example form.html:

<html>
<body>

<form action="process_data.php" method="post">
Search by name: <input type="text" name="search_input">
<input type="submit">
</form>

</body>
</html> 

Then in the PHP file you're calling (I called it process_data.php) just add and change these lines at the top:

//THIS IS JUST A SHORT EXAMPLE. IN THE PRODUCTION/FINAL VERSION YOU MUST SANITISE DATA!!

if (isset($_POST['search_input'])) $search = "WHERE nom = '$_POST[search_input]';
$search = mysqli_real_escape_string($con, $search);

$sql="select * from  association $search ORDER BY id ASC"; 
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda