<?php
	$servername = "localhost";
    $username = "cre12591_rematesduran";
  	$password = "pia1970pia1970";
  	$dbname = "cre12591_crj58049_globalre_login";

	$conn = new mysqli($servername, $username, $password, $dbname);
      if($conn->connect_error){
        die("Conexión fallida: ".$conn->connect_error);
      }

    $salida = "";

    $query = "SELECT * FROM palo WHERE nombre NOT LIKE '' ORDER By num LIMIT 1000";

    if (isset($_POST['consulta'])) {
    	$q = $conn->real_escape_string($_POST['consulta']);
    	$query = "SELECT * FROM palo WHERE num LIKE '%$q%' OR nombre LIKE '%$q%'  OR num LIKE '$q' ";
    }

    $resultado = $conn->query($query);

    if ($resultado->num_rows>0) {
    	$salida.="<table class='table table-striped'>
    			<thead class='bg-warning'>
    				<tr id='titulo'>
    					<td>DESCRIPCION</td>
    					<td></td>
    					<td><a href='nuevoP.php'> <button type='button' class='btn btn-info'>Nuevo</button> </a></td>
    					<td></td>
    				</tr>

    			</thead>
    			

    	<tbody>";

    	while ($filas = $resultado->fetch_assoc()) {
    		$salida.="<tr>
    					<td>".$filas['num']."</td>
    					<td>".$filas['nombre']."</td>
    					<td>  <a href='admpb.php?num=".$filas['num']."'> <button type='button' class='btn btn-success'>MODIFICAR</button> </a>  </td>
    					
    				</tr>";
    				
    				
    			
    				

    	}
    	$salida.="</tbody></table>";
    }else{
        
    	$salida.="<H3> NO SE ENCONTRARON DATOS. </H3> ";
    }


    echo $salida;

    $conn->close();



?>