Jump to content


Photo

Some Os Dados Da Tela


  • Faça o login para participar
2 replies to this topic

#1 anave

anave

    Normal

  • Usuários
  • 107 posts
  • Sexo:Masculino
  • Localidade:Salvador

Posted 12/03/2010, 12:26

No código abaxo uso 2 select uma para escolher o paciente e outro para escolher a categoria.
Quando escolho o paciente, é posicionado ao lado o cpf e nome do paciente.
Quando escolho a categoria tb é posicionado ao lado o nome da categoria, só que nesse exato momento some da tela o cpf e nome do paciente, ñ estou conseguindo detectar onde estou errando.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
        <table width="63%" align="center" border="1">
            <tr>
                <td colspan="3"><b><font size="2">Nome do Paciente:</font></b><Select name="cpf_pac" size="1" id="cpf_pac">
                    <option value="" selected="selected"></option>
                    <?php
						include ("conexao.php");
						$qc="select * from pacientes order by nome_pac asc";
						$rc=mysql_query($qc) or die ("Erro na Selecção do Cliente - BANCO CLIENTES. ".mysql_error());
						
						while ($lc=mysql_fetch_array($rc)){
							$cpf_pac=$lc["cpf_pac"];
							$nome_pac=$lc["nome_pac"];
							
							$cpf_pac=htmlentities($lc["cpf_pac"]);
							$nome_pac=html_entity_decode($nome_pac,ENT_QUOTES);
							
							echo "<option value='$cpf_pac'>$nome_pac</option>";
						
						}
                    ?>
                    <input type="submit" value="OK"/>      
                    </Select>
                    <?php 
						if (!empty($_POST["cpf_pac"])){
							$cpf_pac=$_POST["cpf_pac"];
							
							$sql_pac="select * from pacientes where cpf_pac='$cpf_pac'";
							$rs_pac=mysql_query($sql_pac) or die ("Erro na selecao do PACIENTE. ".mysql_error());
							$l_pac=mysql_fetch_array($rs_pac);
							
							$cpf_pac=$l_pac["cpf_pac"];
							$nome_pac=$l_pac["nome_pac"];
							
							echo "<b><font color=red>$cpf_pac - $nome_pac</a></font></b>";
						}
                    ?>
                </td>
            
            </tr>  
            </table>
            <table width="63%" align="center" border="1">
            <tr>
                <td><b><font size="2">Tipo de Categoria:</font></b><select name="codigo_cat" size="1" id="codigo_cat">
                    <option value='' selected="selected"></option>
                    <?php
						$sql_cat="select * from categoria order by descriscao_cat asc";
						$rs_cat=mysql_query($sql_cat) or die ("Erro ao Conectar Banco - CATEGORIA. ".mysql_error());
						
						while ($l_cat=mysql_fetch_array($rs_cat)){
							$codigo_cat=$l_cat["codigo_cat"];
							$descricao_cat=$l_cat["descriscao_cat"];
							
							$codigo_cat=htmlentities($l_cat["codigo_cat"]);
							$descricao_cat=html_entity_decode($descricao_cat,ENT_QUOTES);
							
							echo "
							<option value='$codigo_cat'>$descricao_cat</option>";
						}
						$data_cadastro = Date('Y/m/d');
						$data_cadastro=date('d/m/Y', strtotime($data_cadastro)); // Converto a data para nosso formato.
                    ?>
                    <input type="submit" value="OK"/>
                </select>
					<?php
                        if(!empty($_POST["cpf_pac"])){
                            $cpf_pac=$_POST["cpf_pac"];
                        }
                        
                        if(!empty($_POST["codigo_cat"])){
                            $codigo_cat=$_POST["codigo_cat"];
                    
                            $sql_cat2="select * from categoria where codigo_cat='$codigo_cat'";
                            $rs_cat2=mysql_query($sql_cat2) or die ("Erro na Seleção da Categoria. ".mysql_error());
                            $l_cat2=mysql_fetch_array($rs_cat2);
                            
                            $codigo_cat=$l_cat2["codigo_cat"];
                            $descricao_cat=$l_cat2["descriscao_cat"];
                            
                            echo "<td colspan='2'><b><font color=red>$codigo_cat - $descricao_cat</a></font></b></td>";
                    ?>
                </td>
                <tr>
                    <td>
                        <b><font size="2">Data de Cadastro:</font></b><input type="text" name="data_cadastro" id="data_cadastro" value="<?php echo $data_cadastro ?>"/>
                    </td>
                    <td width="35%">
                        <b><font size="2">Data da Coleta:</font></b><input type="text" name="data_exame" id="data_exame" />
                    </td>   
                    <td width="25%">
                        <b><font size="2">Hora:</font></b><input type="text" name="hora_exame" id="hora_exame" />
                    </td>
                </tr>
            </tr>
            
            <?php
            } // if(!empty($_POST["codigo_cat"])){
            ?>
        </table> 
        
    </form>
</body>
</html>



#2 digo

digo

    24 Horas

  • Usuários
  • 435 posts
  • Sexo:Masculino

Posted 12/03/2010, 14:50

Fala anave,

O Problema é porque quando você seleciona a categoria deve está enviando o valor de cpf em branco

Fiz umas alterações mas não testei

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
        <table width="63%" align="center" border="1">
            <tr>
                <td colspan="3"><b><font size="2">Nome do Paciente:</font></b>
                <Select name="cpf_pac" size="1" id="cpf_pac">
                    <option value="" <? if (empty($_POST["cpf_pac"]) { ?>selected="selected" <? } ?>></option>
                    <?php
                                                include ("conexao.php");
                                                $qc="select * from pacientes order by nome_pac asc";
                                                $rc=mysql_query($qc) or die ("Erro na Selecção do Cliente - BANCO CLIENTES. ".mysql_error());
                                                
                                                while ($lc=mysql_fetch_array($rc)){
                                                        $cpf_pac=$lc["cpf_pac"];
                                                        $nome_pac=$lc["nome_pac"];
                                                        
                                                        $cpf_pac=htmlentities($lc["cpf_pac"]);
                                                        $nome_pac=html_entity_decode($nome_pac,ENT_QUOTES);
                                                        
                                                        echo "<option value='$cpf_pac'" . if ($_POST["cpf_pac"] == $cpf_pac){ . "selected=\"selected\"" . } . ">$nome_pac</option>";
                                                
                                                }
                    ?>
                          
                    </Select>
                    <?php 
                                                if (!empty($_POST["cpf_pac"])){
                                                        $cpf_pac=$_POST["cpf_pac"];
                                                        
                                                        $sql_pac="select * from pacientes where cpf_pac='$cpf_pac'";
                                                        $rs_pac=mysql_query($sql_pac) or die ("Erro na selecao do PACIENTE. ".mysql_error());
                                                        $l_pac=mysql_fetch_array($rs_pac);
                                                        
                                                        $cpf_pac=$l_pac["cpf_pac"];
                                                        $nome_pac=$l_pac["nome_pac"];
                                                        
                                                        echo "<b><font color=red>$cpf_pac - $nome_pac</a></font></b>";
                                                }
                    ?>
                </td>
            
            </tr>  
            </table>
            <table width="63%" align="center" border="1">
            <tr>
                <td><b><font size="2">Tipo de Categoria:</font></b><select name="codigo_cat" size="1" id="codigo_cat">
                    <option value='' selected="selected"></option>
                    <?php
                                                $sql_cat="select * from categoria order by descriscao_cat asc";
                                                $rs_cat=mysql_query($sql_cat) or die ("Erro ao Conectar Banco - CATEGORIA. ".mysql_error());
                                                
                                                while ($l_cat=mysql_fetch_array($rs_cat)){
                                                        $codigo_cat=$l_cat["codigo_cat"];
                                                        $descricao_cat=$l_cat["descriscao_cat"];
                                                        
                                                        $codigo_cat=htmlentities($l_cat["codigo_cat"]);
                                                        $descricao_cat=html_entity_decode($descricao_cat,ENT_QUOTES);
                                                        
                                                        echo "
                                                        <option value='$codigo_cat'>$descricao_cat</option>";
                                                }
                                                $data_cadastro = Date('Y/m/d');
                                                $data_cadastro=date('d/m/Y', strtotime($data_cadastro)); // Converto a data para nosso formato.
                    ?>
                    <input type="submit" value="OK"/>
                </select>
                                        <?php
                        if(!empty($_POST["cpf_pac"])){
                            $cpf_pac=$_POST["cpf_pac"];
                        }
                        
                        if(!empty($_POST["codigo_cat"])){
                            $codigo_cat=$_POST["codigo_cat"];
                    
                            $sql_cat2="select * from categoria where codigo_cat='$codigo_cat'";
                            $rs_cat2=mysql_query($sql_cat2) or die ("Erro na Seleção da Categoria. ".mysql_error());
                            $l_cat2=mysql_fetch_array($rs_cat2);
                            
                            $codigo_cat=$l_cat2["codigo_cat"];
                            $descricao_cat=$l_cat2["descriscao_cat"];
                            
                            echo "<td colspan='2'><b><font color=red>$codigo_cat - $descricao_cat</a></font></b></td>";
                    ?>
                </td>
                <tr>
                    <td>
                        <b><font size="2">Data de Cadastro:</font></b><input type="text" name="data_cadastro" id="data_cadastro" value="<?php echo $data_cadastro ?>"/>
                    </td>
                    <td width="35%">
                        <b><font size="2">Data da Coleta:</font></b><input type="text" name="data_exame" id="data_exame" />
                    </td>   
                    <td width="25%">
                        <b><font size="2">Hora:</font></b><input type="text" name="hora_exame" id="hora_exame" />
                    </td>
                </tr>
            </tr>
            
            <?php
            } // if(!empty($_POST["codigo_cat"])){
            ?>
        </table> 
        
    </form>
</body>
</html>




#3 anave

anave

    Normal

  • Usuários
  • 107 posts
  • Sexo:Masculino
  • Localidade:Salvador

Posted 15/03/2010, 11:00

Está dando erro na linha 27
echo "<option value='$cpf_pac'". if ($_POST["cpf_pac"] == $cpf_pac){ . "selected=\"selected\"" . } . ">$nome_pac</option>";


Fala anave,

O Problema é porque quando você seleciona a categoria deve está enviando o valor de cpf em branco

Fiz umas alterações mas não testei

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
        <table width="63%" align="center" border="1">
            <tr>
                <td colspan="3"><b><font size="2">Nome do Paciente:</font></b>
                <Select name="cpf_pac" size="1" id="cpf_pac">
                    <option value="" <? if (empty($_POST["cpf_pac"]) { ?>selected="selected" <? } ?>></option>
                    <?php
                                                include ("conexao.php");
                                                $qc="select * from pacientes order by nome_pac asc";
                                                $rc=mysql_query($qc) or die ("Erro na Selecção do Cliente - BANCO CLIENTES. ".mysql_error());
                                                
                                                while ($lc=mysql_fetch_array($rc)){
                                                        $cpf_pac=$lc["cpf_pac"];
                                                        $nome_pac=$lc["nome_pac"];
                                                        
                                                        $cpf_pac=htmlentities($lc["cpf_pac"]);
                                                        $nome_pac=html_entity_decode($nome_pac,ENT_QUOTES);
                                                        
                                                        echo "<option value='$cpf_pac'" . if ($_POST["cpf_pac"] == $cpf_pac){ . "selected=\"selected\"" . } . ">$nome_pac</option>";
                                                
                                                }
                    ?>
                          
                    </Select>
                    <?php 
                                                if (!empty($_POST["cpf_pac"])){
                                                        $cpf_pac=$_POST["cpf_pac"];
                                                        
                                                        $sql_pac="select * from pacientes where cpf_pac='$cpf_pac'";
                                                        $rs_pac=mysql_query($sql_pac) or die ("Erro na selecao do PACIENTE. ".mysql_error());
                                                        $l_pac=mysql_fetch_array($rs_pac);
                                                        
                                                        $cpf_pac=$l_pac["cpf_pac"];
                                                        $nome_pac=$l_pac["nome_pac"];
                                                        
                                                        echo "<b><font color=red>$cpf_pac - $nome_pac</a></font></b>";
                                                }
                    ?>
                </td>
            
            </tr>  
            </table>
            <table width="63%" align="center" border="1">
            <tr>
                <td><b><font size="2">Tipo de Categoria:</font></b><select name="codigo_cat" size="1" id="codigo_cat">
                    <option value='' selected="selected"></option>
                    <?php
                                                $sql_cat="select * from categoria order by descriscao_cat asc";
                                                $rs_cat=mysql_query($sql_cat) or die ("Erro ao Conectar Banco - CATEGORIA. ".mysql_error());
                                                
                                                while ($l_cat=mysql_fetch_array($rs_cat)){
                                                        $codigo_cat=$l_cat["codigo_cat"];
                                                        $descricao_cat=$l_cat["descriscao_cat"];
                                                        
                                                        $codigo_cat=htmlentities($l_cat["codigo_cat"]);
                                                        $descricao_cat=html_entity_decode($descricao_cat,ENT_QUOTES);
                                                        
                                                        echo "
                                                        <option value='$codigo_cat'>$descricao_cat</option>";
                                                }
                                                $data_cadastro = Date('Y/m/d');
                                                $data_cadastro=date('d/m/Y', strtotime($data_cadastro)); // Converto a data para nosso formato.
                    ?>
                    <input type="submit" value="OK"/>
                </select>
                                        <?php
                        if(!empty($_POST["cpf_pac"])){
                            $cpf_pac=$_POST["cpf_pac"];
                        }
                        
                        if(!empty($_POST["codigo_cat"])){
                            $codigo_cat=$_POST["codigo_cat"];
                    
                            $sql_cat2="select * from categoria where codigo_cat='$codigo_cat'";
                            $rs_cat2=mysql_query($sql_cat2) or die ("Erro na Seleção da Categoria. ".mysql_error());
                            $l_cat2=mysql_fetch_array($rs_cat2);
                            
                            $codigo_cat=$l_cat2["codigo_cat"];
                            $descricao_cat=$l_cat2["descriscao_cat"];
                            
                            echo "<td colspan='2'><b><font color=red>$codigo_cat - $descricao_cat</a></font></b></td>";
                    ?>
                </td>
                <tr>
                    <td>
                        <b><font size="2">Data de Cadastro:</font></b><input type="text" name="data_cadastro" id="data_cadastro" value="<?php echo $data_cadastro ?>"/>
                    </td>
                    <td width="35%">
                        <b><font size="2">Data da Coleta:</font></b><input type="text" name="data_exame" id="data_exame" />
                    </td>   
                    <td width="25%">
                        <b><font size="2">Hora:</font></b><input type="text" name="hora_exame" id="hora_exame" />
                    </td>
                </tr>
            </tr>
            
            <?php
            } // if(!empty($_POST["codigo_cat"])){
            ?>
        </table> 
        
    </form>
</body>
</html>







1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq