Change screen data change from the ID that is in Combobox

Asked

Viewed 305 times

0

I am locked in the code where I cannot return all the positions of the ID of the bank in the combobox and I cannot from that ID change the other fields. Any help I thank from now on

Screen of the Data Query

<?php
   session_start();
    $ID_Cliente = $_SESSION['ID_Cliente'];


    $conexao = mysql_connect("localhost:3306","root","root") or die("Erro durante a conexão do banco de dados");
    mysql_select_db("prestadora",$conexao);
    mysql_query("SET NAMES 'utf8'", $conexao);
    mysql_query('SET character_set_connection=utf8', $conexao);
    mysql_query('SET character_set_client=utf8', $conexao);
    mysql_query('SET character_set_results=utf8', $conexao);
    $consulta= "select * from pedido where ClienteID_Cliente='$ID_Cliente' " ;
    $resultado=mysql_query($consulta,$conexao) or die ("Não foi possível Consultar os seus dados.");


      while($consulta=mysql_fetch_array($resultado)){

        $Tipo_Servico=$consulta["Tipo_Servico"];
        $DataVisita=$consulta["DataVisita"];
        $HoraVisita=$consulta["HoraVisita"];
        $EnderecoVisita=$consulta["EnderecoVisita"];          


      }

        $listarID= "select ID_Pedido from pedido " ;
        $lista=mysql_query($listarID,$conexao) or die ("Não foi possível Consultar os seus dados.");


          while($dados=mysql_fetch_array($lista)){

        $ID_Pedido=$dados["ID_Pedido"]; 

         }  

 ?>

Formulario de Alterar

<!DOCTYPE html>

<html>
<head>
    <title>Projeto Web-AlterarPedido</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../_css/layoutPrincipal.css">
    <link rel="stylesheet" href="../_css/formulario.css">

</head>
<body>

<header id="cabecalho">
    <img src="../_imagens/logo.jpg">
</header>
<br class="fixFloat">
<nav id="menu">
    <ul>
        <li><a href="../index.html" target="_self">Home</a></li>
        <li><a href="../cadastra-se.html" target="_self">Cadastra-se</a></li>
        <li><a href="../login.html" target="_self">Login</a></li>
    </ul>
</nav>



<section id="form">
    <fieldset id="form_field">
        <legend id="form_legend">Alterar Pedido</legend>

         <?php
        include "listarpedido.php";
              ?>

              <form method="post" action="alterarpedido.php">
                 Escolher qual alterar: <select name="ID_Pedido" id="ID" >
                 <option value="<?php echo $ID_Pedido;?>"><?php echo $ID_Pedido;?></option> 
                  </select><br/><br/>
                 Tipo de Serviço: <select name="Tipo_Servico"  value="<?php echo $Tipo_Servico;?>">
                 <option name="Reforma Predial">Reforma Predial</option>
                 <option name="Jardinagem">Jardinagem</option>
                 <option name="Eletricista">Eletricista</option>
                 <option name="Encanador">Encanador</option>
                 </select> 
                 Data de Visita: <input type="text" name="DataVisita" value="<?php echo $DataVisita;?>">  
                 Hora de Visita: <input type="text" name="HoraVisita" value="<?php echo $HoraVisita;?>"><br/><br/>
                 Endereço de Visita: <input type="text" name="EnderecoVisita" value="<?php echo $EnderecoVisita;?>" >
                <fieldset id="form_field">
                      <legend id="form_legend">Alterar</legend>
                      <input type="submit" id="botao" value="Alterar">
                      <input type="reset" id="botao" value="Resetar">
                </fieldset>
            </form>

</section>


</body>
</html>

Query Screen to Change Data in Database

<!DOCTYPE html>

<html>
<head>
    <title>Projeto Web-AlterarCadastro</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../_css/layoutPrincipal.css">
    <link rel="stylesheet" href="../_css/formulario.css">

</head>
<body>

<header id="cabecalho">
    <img src="../_imagens/Logo.jpg">
</header>
<br class="fixFloat">
<nav id="menu">
    <ul>
        <li><a href="../index.html" target="_self">Home</a></li>
        <li><a href="../cadastra-se.html" target="_self">Cadastra-se</a></li>
        <li><a href="../login.html" target="_self">Login</a></li>
    </ul>
</nav>


<section id="form">
    <?php

    $ID_Pedido=$_POST["ID_Pedido"];
    $Tipo_Servico=$_POST["$Tipo_Servico"];
    $DataVisita=$_POST["DataVisita"];
    $HoraVisita=$_POST["HoraVisita"];
    $EnderecoVisita=$_POST["EnderecoVisita"];




    $conexao = mysql_connect("localhost:3306","root","root") or die("Erro durante a conexão do banco de dados");
    mysql_select_db("prestadora",$conexao);
    mysql_query("SET NAMES 'utf8'", $conexao);
    mysql_query('SET character_set_connection=utf8', $conexao);
    mysql_query('SET character_set_client=utf8', $conexao);
    mysql_query('SET character_set_results=utf8', $conexao);
    $atualiza= "update cliente set Tipo_Servico='$Tipo_Servico',DataVisita='$DataVisita',HoraVisita='$HoraVisita',EnderecoVisita='$EnderecoVisita' WHERE ID_Pedido='$ID_Pedido'" ;
    mysql_query($atualiza,$conexao) or die ("Não foi possível executar a atualização.");
    mysql_close($conexao);



    echo"<fieldset id='form_field'><legend id='form_legend'>Dados do Pedido</legend>
  <p>Dados do Pedido Alterados com Sucesso !!!</p></fieldset>";



    ?>
<fieldset id="form_field">
     <legend id="form_legend">Voltar</legend>
    <a href="../menucliente.html" id="botao">Voltar</a>
</fieldset>

</section>


</body>
</html>
  • Not use Trecho de código (Stack Snippets) for PHP, read: http://meta.pt.stackoverflow.com/q/2115/3635

    1. http://answall.com/questions/178868/recuperar-e-armazr-o-id-apartir-de-umatela-de-login-para-usar-em-outras-tela 2. http://answall.com/questions/180948/recuperar-um-id-e-inserir-no-combobox-para-altered 3. http://answall.com/questions/181240/mudar-o-dados-da-tela-alterar-a-partir-do-id-que-est%C3%a1-no-combobox

1 answer

1

Initially: in your "Query Data Screen", when reading the returned values (within "while"), you only assign the results to the variables.

You need to print them for the user, along with some markup, be it a link, a select (combo) and their respective options, or something like that.

  • It became too vague I didn’t understand it right and how I would do it ?

  • the loop I manage to do but change the fields according to the ID,I have no idea how to do this

Browser other questions tagged

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