Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername ="localhost";
- $username="root";
- $password="";
- $dbname="casaldogrilo";
- //cria conexão
- $conn = new mysqli($servername, $username, $password, $dbname);
- // verifica conexão
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM juniores order by Nome ASC";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- echo "<table style='width:100%' height='100%'>
- <tr>
- <th>Nome</th>
- <th>Data_Nasc</th>
- <th>Idade</th>
- <th>Nacionalidade</th>
- </tr>";
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<tr>
- <td align='center'>".$row["Nome"]."</td>
- <td align='center'>".$row["Data_Nasc"]."</td>
- <td align='center'>".$row["Idade"]."</td>
- <td align='center'>".$row["Nacionalidade"]."</td>
- </tr>";
- }
- echo "</table>";
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
- if ($result->num_rows > 0) {
- echo "<table style='width:100%' height='100%'>
- <tr>
- <th>Nome</th>
- <th>Data_Nasc</th>
- <th>Idade</th>
- <th>Nacionalidade</th>
- </tr>";
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo '<tr>
- <td align="center"><a href="jogador.php?id=' .$row["id"]. '">' .$row["Nome"]. '</a></td>
- <td align="center">' .$row["Data_Nasc"]. '</td>
- <td align="center">' .$row["Idade"]. '</td>
- <td align="center">' .$row["Nacionalidade"]. '</td>
- </tr>';
- }
- echo "</table>";
- <?php
- if(!isset($_GET['id'])) {
- die('Não existe um id definido');
- }
- if(!is_numeric($_GET['id'])) {
- die('ID inválido');
- }
- else {
- $servername = "localhost"; $username = "root"; $password = ""; $dbname = "casaldogrilo"; // cria conexão
- $conn = new mysqli($servername, $username, $password, $dbname); // verifica conexão
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM juniores WHERE id=" .$_GET['id'];
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- $jogador = $result->fetch_assoc();
- echo 'Nome: ' .$jogador['Nome'];
- echo 'Data Nascimento: ' .$jogador['Data_Nasc'];
- echo 'Idade: ' .$jogador['Idade'];
- echo 'Nacionalidade: ' .$jogador['Nacionalidade'];
- }
- else {
- echo 'Jogador não encontrado';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement