How to view the data registered on another page

Asked

Viewed 460 times

3

Hello friends how could make registered data appear on another page in a table ? inserir a descrição da imagem aqui

That is the code

<form method="post" action="index.php" onSubmit="">
        <fieldset>
            <legend>Sistema de Inventário</legend><br />

            <label class="borda">Setor: </label>
            <input class="form_inp" type="text" name="setor" size="30" required><br />

            <label class="borda">Usuário:</label>
            <input class="form_inp" type="text" id="usuario" name="usuario" size="30" required><br />

            <label class="borda">O/S :</label>
            <input class="form_inp" type="text" name="os" size="30" required><br /><br />

            <label class="borda">Hd : </label>
            <input  class="form_inp"type="text"  name="hd" size="30" required><br />                        
            <hr />          
            <label class="borda">Memória:</label>
            <input class="form_inp" type="text" id="" name="memoria" size="30" required><br />

            <label class="borda">Processador: </label>
            <input class="form_inp" type="text" id="processador"  name="processador" size="30" required><br /><br />
            <hr />
            <label class="borda">Cd/Dvd: </label>
            <select class="form_inp"  name="cd"> 
                <option value="Sim">Sim</option> 
                <option value="Não">Não</option> 
            </select>

            <br />

            <label class="borda">Placa Mãe: </label>
            <input class="form_inp" type="text" id="placam" name="placam" size="30" required><br />

            <label class="borda">HostName: </label>
            <input class="form_inp"type="text" id="host" name="host" size="30" required><br /><br />

            <label class="borda">Monitor/Patrimônio/Marca/Modelo: </label>
            <input class="form_inp" type="text" id="monitor" name="monitor" size="30" required><br />

            <label class="borda">Nobreak/Patrimônio/Marca/: </label>
            <input class="form_inp" type="text" id="nobreak" name="nobreak" size="30" required><br />

            <label class="borda">Placa de Rede : </label>
            <input class="form_inp" type="text" id="placar" name="placar" size="30" required><br />

            <label class="borda">Placa de Vídeo: </label>
            <input class="form_inp" type="text" id="placav" name="placav" size="30" required><br />

            <hr />
            <input type="submit" style="float: right;" value="Cadastrar" >
            <input type="reset" style="float: right;" value="Limpar">

        </fieldset>
    </form>

       <?php

        error_reporting(-1);
        ini_set('display_errors', 'On');


        $servidor = "localhost";
        $usuario = "root";
        $senha = "";
        $dbname = "cadastro";

        //Criar a conexao
        $link = new mysqli ("localhost", "root", "", "cadastro");
        if($link->connect_errno){
             echo"Nossas falhas local experiência ..";
             exit();
         }

        if($_SERVER['REQUEST_METHOD'] == 'POST') {
                print_r($_POST);
                $setor=$_POST['setor'];
                $usuario=$_POST['usuario'];
                $hd=$_POST['hd'];
                $memoria=$_POST['memoria'];
                $processador=$_POST['processador'];
                $cd=$_POST['cd'];
                $placam=$_POST['placam'];
                $host=$_POST['host'];
                $monitor=$_POST['monitor'];
                $nobreak=$_POST['nobreak'];
                $placar=$_POST['placar'];
                $placav=$_POST['placav'];
                $sql="INSERT INTO setor(setor,usuario,hd,memoria,processador,cd,placam,host,monitor,nobreak,placar,placav) VALUES('$setor','$usuario','$hd','$memoria','$processador','$cd','$placam','$host','$monitor','$nobreak','$nobreak','$placav')";
                $resultado_cadastro = mysqli_query($link,$sql);
        }

    ?>
  • 1
  • It’s hard to understand...

  • has this registration screen and I want to see what was registered on another page.

  • Recovering data from last record and showing on other page would not work?

  • Yes, not only the last entry, but everyone . How do I @Shutupmagda

1 answer

2


Considering that the data you want to list is already saved in a database, it is not very difficult.

Create the new page, make your connection to the database, and then run your query by picking up the results. Example (using mysql_query and whereas you will use PHP):

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Lista de Cadastros</title> </head> <body> <h1>Estes são os cadastros</h1> <?php //A CONEXÃO COM O BANCO VAI AQUI... ?> <?php $result = mysql_query(SELECT campo1, campo2, campo3..., campoN FROM nomeDaTabela); ?> <table> <tr>
<th>Dado 1</th> <th>Dado 2</th> <th>Dado 3</th> <th>Dado N</th> </tr> <?php while($row = mysql_fetch_array($result)) : ?> <tr> <td><?= $row['campo1']; ?></td> <td><?= $row['campo2']; ?></td> <td><?= $row['campo3']; ?></td> <td><?= $row['campoN']; ?></td> </tr> <?php endwhile; ?> </table> </body> </html>

Note: mysql_query is deprecated. Look to use PDO. There are many tutorials on the internet teaching how to do.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.