Adapt a .PHP file to .HTML to insert Javascript and filter tables

0

 var busqueda = document.getElementById('buscar');
    var table = document.getElementById("tabla").tBodies[0];

    buscaTabla = function() {
      texto = busqueda.value.toLowerCase();
      var r = 0;
      while (row = table.rows[r++]) {
        if (row.innerText.toLowerCase().indexOf(texto) !== -1)
          row.style.display = null;
        else
          row.style.display = 'none';
      }
    }

    busqueda.addEventListener('keyup', buscaTabla);
<?php
// Establecer conexión

session_start();
require_once "conexion_root.php";
?>
<?
// Ejecución de consulta SQL
 
$sql = "SELECT * FROM equipos"; 

if($result = $db_conn-><?query($sql)){
if($result-><?num_rows ><? 0){
?>
<html>
<head>
<meta charset="UTF-8">
<title>Inventario de Equipos</title>
<link href="./roundedcorners2.css" rel="stylesheet" type="text/css" />
<link href="./result.css" rel="stylesheet" type="text/css" />
</head>
	<body> 			
		<p align="center"><a href="inventario.html"><img src="img\att_logo.png" width="150px"/></a></p>
		<p><h1 align="center" style="font-family: calibri">Inventario de Equipos</h1></p><br>
		
		<p><input id="buscar" type="text" class="form-control" placeholder="Escriba algo para filtrar" /></p>

			<table id="tabla" class="roundedCorners2">				
				<thead>			
				<tr>
					<th>Tipo de Equipo:</th>
					<th>Número de Serie:</th>					
					<th>Marca:</th>
					<th>Modelo:</th>					
					<th>Unidades:</th>					
					<th>Proyecto:</th>					
					<th>Coordenadas del Rack:</th>					
					<th>Unidad_Inicial:</th>					
					<th>Unidad_Final:</th>					
					<th>Estado:</th>					
					<th>Situación:</th>					
					<th>Stack/Cluster:</th>					
					<th>Hostname:</th>					
					<th>IP Admin:</th>					
					<th>IOS:</th>					
					<th>Activo Fijo:</th>									
					<th>Notas: </th>					
			    </tr>

  
       <? while($row = $result-><?fetch_array())<?{?>

				<tbody>			
				<tr>
					<td><? . $row['tipo_equipo'] . ?></td>
					<td><? . $row['no_serie'] . ?></td>					
					<td><? . $row['marca'] . ?></td>
					<td><? . $row['modelo'] . ?></td>			
					<td><? . $row['unidades'] . ?></td>					
					<td><? . $row['proyecto'] . ?></td>
					<td><? . $row['coordenadas_rack'] . ?></td>
					<td><? . $row['unidad_inicial'] . ?></td>
					<td><? . $row['unidad_final'] . ?></td>				
					<td><? . $row['estado'] . ?></td>
					<td><? . $row['situacion'] . ?></td>			
					<td><? . $row['stack_cluster'] . ?></td>
					<td><? . $row['hostname'] . ?></td>
					<td><? . $row['ip_admin'] . ?></td>					
					<td><? . $row['ios'] . ?></td>				
					<td><? . $row['activo_fijo'] . ?></td>						
					<td><? . $row['notas'] . ?></td>								
				</tr>		
				</tbody>				
			<? } ?>

			</table><br>	
						
	<div>	
		<table id="resultados" class="result">
			<tr>
				<td>	
				<?
					// Determinar el número de filas del resultado 
					$row_cnt = $result-><?num_rows;	
					
					<?printf("%d resultado(s) encontrado(s).\n", ?><?$row_cnt); 
				</td>				
			</tr>
		</table>
	</div>	
	</body>
</html>
    
asked by Antonio Ortiz 21.12.2017 в 22:13
source

0 answers