<!DOCTYPE html>
<html lang="PT-br">
    <?php include_once '../paginas/header.php';?>
<body>
    <?php include_once '../paginas/menu.php';?>

    <div class="services-details-area default-padding">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12">
                    <div class="col-lg-8">
                        <h2>Lista de respostas</h2>
                        
                        <br>
                       <!-- <form>
							<input name="pesquisar" id="pesquisar" class="form-control" type="text" placeholder="Pesquisar"><br>
							<input class="btn btn-success pull-right"  type="submit" value="Pesquisar / Limpar pesquisa"><br>
                            <br>
                            <br>
						</form>-->
                    </div>
                    <?php
                    // Include config file
                    require_once "../banco/config.php";

                   // $pescliente_id = $_GET['pesquisar'];
                    
                    // Attempt select query execution
                    $sql = "SELECT * FROM clientes, respostas  WHERE clientes.id=respostas.cliente_id";
                    if($result = mysqli_query($link, $sql)){
                        if(mysqli_num_rows($result) > 0){
                            echo '<table class="table table-bordered table-striped">';
                                echo "<thead>";
                                    echo "<tr>";
                                        echo "<th>Id respostas</th>";
                                        echo "<th>Cliente</th>";
                                        echo "<th>Perguntas</th>";
                                        echo "<th>Data</th>";
                                        echo "<th>Ações</th>";
                                    echo "</tr>";
                                echo "</thead>";
                                echo "<tbody>";
                                while($row = mysqli_fetch_array($result)){
                                    echo "<tr>";
                                        echo "<td>" . $row['id'] . "</td>";
                                        echo "<td>" . $row['nome'] . "</td>";
                                        echo "<td>" . $row['pergunta_id'] . "</td>";
                                        echo "<td>" . $row['data'] . "</td>";
                                        echo "<td>";
                                            echo '<a href="../aplicacao/editarrespostas.php?id='. $row['cliente_id'] .'" class="mr-3" title="Update Record" data-toggle="tooltip"><span class="fa fa-pencil"></span></a>';
                                            echo '<a href="../aplicacao/deleterespostas.php?id='. $row['id'] .'" title="Delete Record" data-toggle="tooltip"><span class="fa fa-trash"></span></a>';
                                        echo "</td>";
                                    echo "</tr>";
                                }
                                echo "</tbody>";                            
                            echo "</table>";
                            // Free result set
                            mysqli_free_result($result);
                        } else{
                            echo '<div class="alert alert-danger"><em>No records were found.</em></div>';
                        }
                    } else{
                        echo "Oops! Something went wrong. Please try again later.";
                    }
 
                    // Close connection
                    mysqli_close($link);
                    ?>
                </div>
            </div>        
        </div>
    </div>
    <?php include_once '../paginas/foorter.php';?>
</body>
</html>