Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

yagojunio

[Resolvido] Formulario

Recommended Posts

Bom Dia,

sou novo no ramo e preciso que que possibilita fazer o cadastro desta tabela, cadastro completo: INCLUIR, EXCLUIR, ALTERAR E PESQUISAR.

Na primeira pagina os comandos são:

 

-->ELE SE CONECTA COM O BANCO E APARECE NA TELA PRINCIPAL

 

 

<?php

$conn = mysql_connect("localhost", "root", "flex") or die('Erro ao conectar no Servidor!');

mysql_select_db("joomla_professoronline",$conn) or die('Erro ao selecionar banco!');

$sql = "SELECT codigo, nome, descricao, endereco, telefone, website,bairro  
       FROM  prf_unidade";        

$result = mysql_query($sql) or die('Erro ao executar consulta');

/*$resulte = mysql_fetch_array($result);*/




if (!$result) {
   echo "Não foi possível executar a consulta ($sql) no banco de dados: " . mysql_error();
   exit;
}
?>

<html>
 <head>
 <meta http-equiv="content-type" content="text/html; charset=windows-1250">
 <meta name="generator" content="PSPad editor, www.pspad.com">
 <title>Gerenciador de Uso dos Professores.</title>
 <html>
 <script type="text/javascript">
   function Alterar(){ 
  document.form1.submit() ;
  return false;
}   

  function Excluir() {
       var answer = confirm("Deseja Excluir este usuario?")
       if (answer){
               window.location = "form_professor.php";
       }
       else{

       }
       }
</script>

 </head>
 <body>
 <center>

     <div style="border: 3px black solid; width:1075px; height:510px" > 
       <br />
          <form method= GET action="form_professor_homepage.php" name="form1">

           <table align="center" style="background:darkgray; ">
<tr>            
           <td><font style="font-size:20px;font-family:Comic-Sans">Codigo</font></td>
           <td><font style="font-size:20px;font-family:Comic-Sans">Nome</font></td>
           <td><font style="font-size:20px;font-family:Comic-Sans">Descri&ccedilao</font></td>
           <td><font style="font-size:20px;font-family:Comic-Sans">Endere&ccedilo</font></td>        
           <td><font style="font-size:20px;font-family:Comic-Sans">Bairro</font></td>       
           <td><font style="font-size:20px;font-family:Comic-Sans">WebSite</font></td> 
           <td><font style="font-size:20px;font-family:Comic-Sans">Telefone</font></td>
</tr>  
<?php 
while ( $row = mysql_fetch_array ( $result , MYSQL_BOTH )) { 

?>
<tr>
           <td><input  type= radio readonly name="codigo" value="<?php echo $row['codigo'];?>"></td>
            <td><input type=text name="nome" readonly maxlength="50" value="<?php echo $row['nome'];?>"></td>
            <td><input type=text name="descricao" readonly maxlength="200" value="<?php echo $row['descricao'];?>" ></td>
            <td><input type=text name="endereco" readonly maxlength="50" value="<?php echo $row['endereco'];?>"></td>
            <td><input type=text name="bairoo" readonly maxlength="50" value="<?php echo $row['bairro'];?>"></td>
            <td><input type=text name="website" readonly maxlength="50" value="<?php echo $row['website'];?>"></td>
            <td><input type=text name="telefone" readonly maxlength="12" value="<?php echo $row['telefone'];?>" OnKeyPress="formatar('##-####-####', this)"></td>
<?php } ?>
</tr>   

          <div style="border: 3px goldenrod solid; background: goldenrod; width:1069px; height:84px">
              <div  style="width:450px; height:85px;" >

                  <span  style="float: left;"><a href='#' onclick="Alterar()" style="text-decoration: none;">
                          <img src="../Alterar.png" width="56" height="56" />
                          <br> Alterar</a></span>

                  <span  style="float: left;"><a href='#' onclick="Excluir()" style="text-decoration: none;">
                          <img src="../excluir.gif" width="56" height="56" />
                          <br> Excluir</a></span> 

                  <span  style="float: left;"><a href='#' style="text-decoration: none;">
                          <img src="../incluir.png" width="56" height="56" />
                          <br> Incluir</a></span>

                  <span style="float: left;"><a href='' style="text-decoration: none;">
                          <img src="../pesquisar.png" width="56" height="56" />
                          <br> Pesquisar</a></span>
          </div>
           </table>
     </form>
     </center>
     </div>
  </body>
</html>

---------------------------------------------------

em seguida quando clicado e ele chama outra pag que realiza as funçoes na qual eu nao sei mais fazer apartir dai.

<?php

$conn = mysql_connect("localhost", "root", "flex") or die('Erro ao conectar no Servidor!');

mysql_select_db("joomla_professoronline",$conn) or die('Erro ao selecionar banco!');

$sql = "SELECT codigo, nome, descricao, endereco, telefone, website,bairro
       FROM  prf_unidade";        

$result = mysql_query($sql) or die('Erro ao executar consulta');

$resulte = mysql_fetch_array($result);

if (!$result) {
   echo "Não foi possível executar a consulta ($sql) no banco de dados: " . mysql_error();
   exit;
}

?>

<html>
 <head>
 <meta http-equiv="content-type" content="text/html; charset=windows-1250">
 <meta name="generator" content="PSPad editor, www.pspad.com">
 <title>Gerenciador de Uso dos Professores.</title>
 <html>
 <script type="text/javascript">
function Confirmar(){ 
 document.form1.submit() ;
 alert("Dados Inseridos com Sucesso");
 window.location = "form_professor.php";
 return false;
}

function formatar(mascara, documento){
 var i = documento.value.length;
 var saida = mascara.substring(0,1);
 var texto = mascara.substring(i)

 if (texto.substring(0,1) != saida){
           documento.value += texto.substring(0,1);
 }
}
</script>

 </head>
 <body> 
<center>

     <div style="border: 3px black solid; width:1075px; height:510px" > 
       <br />
          <form method= GET action="form_professor_homepage.php" name="form1">

           <table align="center" style="background:darkgray; ">
<tr>            
           <td><font style="font-size:20px;font-family:Comic-Sans">Codigo</font></td>
           <td><font style="font-size:20px;font-family:Comic-Sans">Nome</font></td>
           <td><font style="font-size:20px;font-family:Comic-Sans">Descri&ccedilao</font></td>
           <td><font style="font-size:20px;font-family:Comic-Sans">Endere&ccedilo</font></td>        
           <td><font style="font-size:20px;font-family:Comic-Sans">Bairro</font></td>       
           <td><font style="font-size:20px;font-family:Comic-Sans">WebSite</font></td> 
           <td><font style="font-size:20px;font-family:Comic-Sans">Telefone</font></td>
</tr>  
<tr>
            <td><input type = text align:right readonly name="codigo" value="<?php echo $resulte['codigo'];?>"> </td>
            <td><input type = text name="nome"  maxlength="50" value="<?php echo $resulte['nome'];?>"></td>
            <td><input type = text name="descricao"  maxlength="200" value="<?php echo $resulte['descricao'];?>" ></td>
            <td><input type = text name="endereco" maxlength="50" value="<?php echo $resulte['endereco'];?>"></td>
            <td><input type = text name="bairoo"  maxlength="50" value="<?php echo $resulte['bairro'];?>"></td>
            <td><input type = text name="website"  maxlength="50" value="<?php echo $resulte['website'];?>"></td>
            <td><input type = text name="telefone"  maxlength="12" value="<?php echo $resulte['telefone'];?>" OnKeyPress="formatar('##-####-####', this)"></td>
</tr>   

          <div style="border: 3px goldenrod solid; background: goldenrod; width:1069px; height:84px">
              <div  style="width:450px; height:85px;" >

                  <span  style="float: left;"><a href='#' onclick="Confirmar()" style="text-decoration: none;">
                          <img src="../confirmar.gif" width="56" height="56" />
                          <br>Confirmar</a></span>

                  <span  style="float: left;"><a href='form_professor.php' onclick="Cancelar()" style="text-decoration: none;">
                   <img src="../cancelar.png" width="56" height="56" />
                          <br> Cancelar</a></span> 


          </div>
           </table>
     </form>
     </center>
     </div>
  </body>
</html>

----------------------------------------------------------------------------------


--> Conectando com a tabela

<?php
//Seleciona no Banco da Dados

$conn = mysql_connect("localhost", "root", "flex") or die('Erro ao conectar no Servidor!');

mysql_select_db("joomla_professoronline",$conn) or die('Erro ao selecionar banco!');


$codigo = $_GET["codigo"];
$nome = $_GET["nome"];
$descricao = $_GET["descricao"];
$endereco = $_GET["endereco"];
$telefone = $_GET["telefone"];
$website = $_GET["website"];
$bairro = $_GET["bairro"];

$sql = "select * from prf_unidade ";
$resultado = mysql_query($sql)
or die (mysql_error());


//Altera os Dados no banco
$codigo = $_GET["codigo"];
$nome = $_GET["nome"];
$descricao = $_GET["descricao"];
$endereco = $_GET["endereco"];
$telefone = $_GET["telefone"];
$website = $_GET["website"];
$bairro = $_GET["bairro"];

$sql = "update prf_unidade set nome = '$nome',
           descricao = '$descricao',
           endereco = '$endereco',
           telefone = '$telefone',
           bairro = '$bairro',
           website = '$website'
           where codigo = '$codigo'";    

$resultado = mysql_query($sql)
or die (mysql_error());

echo "Dados inseridos com sucesso!";
?>

 

 

 

ME AJUDEM POR FAVOR

Compartilhar este post


Link para o post
Compartilhar em outros sites

yagojunio, é preciso saber qual a sua dúvida pra alguém tentar ajudar.

 

 

como eu faço para selecionar somente 1 dos resultados da pesquisa e como que deletar, alterar.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Sua dúvida é no php então? Ou tem alguma coisa de css?

 

no php.

pq tipo quando eu visualizo os campos na 1º pag gostaria que na outra pagina aprecesse os dados seleccionados.

e pudesse alterar

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.