Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Recebe dados do formulário
- $id = $_GET['id'];
- $nome = $_GET['nome'];
- $email = $_GET['email'];
- $nota = $_GET['nota'];
- $idCurso = $_GET['idCurso'];
- ?>
- <html lang="pt-br">
- <head>
- <meta charset='UTF-8'/>
- <title> Escola </title>
- </head>
- <body>
- <h3> Edição de Aluno </h3>
- <form method='post' action='atualizar.php'>
- <?php
- print "
- <input type='hidden' name='id' value='$id'>
- ========<input type='hidden' name='idCurso' value='$idCurso'>
- <label>Nome</label>
- <input name='nome' value='$nome'/><br>
- <label>E-mail</label>
- <input name='email' type='email' maxlength='20' value='$email'/><br>
- <label>Nota</label>
- <input name='nota' value='$nota'/><br>
- <label>Curso</label>
- <select name='cursos'>
- <option value='000'>Selecione:</option>
- ";
- //Conectando com o BD
- $ds = 'mysql:host=localhost;dbname=bdif';
- $user = 'root';
- $pass = 'vertrigo';
- $db = new PDO($ds, $user, $pass);
- #Definindo o SQL
- $query = 'SELECT idCurso, curso FROM tbcurso order by curso ASC';
- $stm = $db->prepare($query);
- if($stm->execute()){
- while($row = $stm->fetch()){
- $id = $row['idCurso'];
- $curso = $row['curso'];
- if ($idCurso == $id) {
- print "<option value='$id' selected='selected'>$curso</option>";
- }
- else {
- print "<option value='$id'>$curso</option>";
- }
- }
- }
- else{
- print "<p>Erro ao listar os cursos</p>";
- print_r($stm->errorInfo());
- }
- print "</select>";
- ?>
- <button type='submit'>atualizar</button>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement