Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('conexao2.php');
- ?>
- <!DOCTYPE html>
- <html lang="pt-br">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <title>Sistema de Busca</title>
- </head>
- <body>
- <div class="container">
- <br><br>
- <h1>Pesquisa de Links</h1>
- <form action="">
- <input name="busca" size="64" value="<?php if(isset($_GET['busca'])) echo $_GET['busca']; ?>" placeholder="O que você deseja pesquisar?" type="text">
- <button type="submit">Pesquisar</button>
- </form>
- <br>
- <table width="600px" border="1">
- <tr>
- <th>Nome</th>
- <th>url</th>
- <th>Data de cadastro</th>
- </tr>
- <?php
- if (!isset($_GET['busca'])) {
- ?>
- <tr>
- <td colspan="3">Digite algo para pesquisar...</td>
- </tr>
- <?php
- } else {
- $pesquisa = $mysqli->real_escape_string($_GET['busca']);
- $sql_code = "SELECT *
- FROM url
- WHERE nome LIKE '%$pesquisa%'
- OR palavras_chave LIKE '%$pesquisa%'";
- $sql_query = $mysqli->query($sql_code) or die("ERRO ao consultar! " . $mysqli->error);
- if ($sql_query->num_rows == 0) {
- ?>
- <tr>
- <td colspan="3">Nenhum resultado encontrado...</td>
- </tr>
- <?php
- } else {
- while($dados = $sql_query->fetch_assoc()) {
- ?>
- <tr>
- <td><?php echo $dados['nome']; ?></td>
- <td><?php echo $dados['url']; ?></td>
- <td><?php echo $dados['data']; ?></td>
- </tr>
- <?php
- }
- }
- ?>
- <?php
- } ?>
- </table>
- <br><br>
- <a href="index.php">Voltar para o início</a>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement