PHP - Buscador registros tabla mysql

 
Vista:
Imágen de perfil de Cesar
Val: 67
Ha aumentado su posición en 4 puestos en PHP (en relación al último mes)
Gráfica de PHP

Buscador registros tabla mysql

Publicado por Cesar (24 intervenciones) el 30/06/2019 12:41:25
Buenas y gracias de antemano ,
Mi problema es que cuando me bajo ejemplos de bootstrap de la pagina de w3schools me funcionan bien
pero cuando los inserto en mi codigó , no funcionan

Ejemplo de un buscador con jquery :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
 
<div class="container">
  <h2>Filterable Table</h2>
  <p>Type something in the input field to search the table for first names, last names or emails:</p>
  <input class="form-control" id="myInput" type="text" placeholder="Search..">
  <br>
  <table class="table table-bordered table-striped">
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody id="myTable">
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@mail.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@greatstuff.com</td>
      </tr>
      <tr>
        <td>Anja</td>
        <td>Ravendale</td>
        <td>a_r@test.com</td>
      </tr>
    </tbody>
  </table>
 
  <p>Note that we start the search in tbody, to prevent filtering the table headers.</p>
</div>
 
<script>
$(document).ready(function(){
  $("#myInput").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#myTable tr").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});
</script>
 
</body>
</html>
funciona bien pero al hacerlo con una tabla traida de mysql no me lo reconoce
creo que el error esta en los <tr> ya que los que taigo de la tabla son asi:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<table class="table table-bordered table-striped">
	 <tr>
	<thead>
	      <th>NOMBRE</th>
	      <th>SELLO</th>
	      <th>ZONA</th>
	      <th>DESVIO</th>
	      <th>COLOR</th>
		  <th>ENLACE</th>
	</thead>
 
<?php
 
 
  for($i=0; $i<$lista_STOCK; $i++){
echo'<tr>';
	echo '<td>'.$lista_STOCK['NOMBRE'].'</td>';
	echo '<td>'.$lista_STOCK['SELLO'].'</td>';
	echo '<td>'.$lista_STOCK['ZONA'].'</td>';
	echo '<td>'.$lista_STOCK['DESVIO'].'</td>';
	echo '<td>'.$lista_STOCK['COLOR'].'</td>';
echo '<td><a href="imagenes/'.$lista_STOCK['FOTO1'].'.jpg">FOTO </a></td>';
 
echo'<tr>';
  $lista_STOCK = mysqlI_fetch_array($resultado);
}
    ?>
 
        </tr>
      </table>

Gracias y un saludo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 24
Ha aumentado su posición en 3 puestos en PHP (en relación al último mes)
Gráfica de PHP

Buscador registros tabla mysql

Publicado por Xavi (12 intervenciones) el 02/07/2019 13:21:21
Hola,
El código html sácalo de php y sólo pon las variables dentro de php. Algo así.
<td> <?php echo .$lista_STOCK['NOMBRE'];?> </td>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar