Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  
SirSmart

Alteração

Question

Galera eu fiz um script de alteração onde eu mostro o cliente que vai ser alterado e seus dependentes.

O problema é que o cliente é um "form" e o dependente é outro "form", mas os dois são exibidos na mesma tela.

Depois se exibi-lo eu preciso salvar, como eu faço pra saber em que tabela do meu banco eu salvo o cliente e em que tabela so meu banco eu salvo o dependente?

Como eu poderia fazer isso de uma maneira mais fácil??

Se alguém puder me ajudar eu agradeço

Obrigado

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Segura:

session_start();

if($_SESSION['name']==NULL){
  header("location:login.php");
}
else{
echo '<body background="C:\www\cassia\imagens\background.png">';
$nome=$_POST['nome'];
$codigo=$_POST['codigo'];
$cnpj=$_POST['cnpj'];
$cpf=$_POST['cpf'];
  	
$mysql = mysql_connect("localhost","root","copernic");
$mysql_db = mysql_select_db("dados");
  	
echo '<br><br>';
echo '<a href="menu.php">Menu</a>';
echo '<br><br>';
echo '<form method="post" action="alteracao.php"  name="form1" >';

if($nome!=''){
$result = mysql_query("select *from tab_cli where nome = '$nome'") or die ("Erro " .mysql_error());

$num_rows = mysql_num_rows($result);
  
if(!$result){
echo 'NÃO POSSIVEL FAZER A CONSULTA';
}	
    
if($num_rows < 1){
 //echo 'CODIGO NÃO ENCONTRADO';
}else{

echo '<center><h2>ALTERAÇÃO DE CLIENTE</h2></center>';
echo '<br><br>';
echo '<table border=3>';
while ($row = mysql_fetch_array($result)) {

echo '<body >';
  
echo'<b>Codigo do Titular:</b>';
      
echo '<input type="text" name="cod_titu" value="'.$row[2].'" maxlength="8" size="8" tabindex="1" onkeypress=blockenter();  >';
echo '<br><br>';
      
echo '<b>Nome:</b><input type=text name="nome" maxlength="50" value="'.$row[3].'" size="50" tabindex="2"  >';
    	
if($row[4]=="M") $selected_S = " SELECTED"; else $selected_S = "";
if($row[4]=="F") $selected_C = " SELECTED"; else $selected_C = "";
    	
      echo '<b> Sexo:</b><select name="sexo" value="'.$row[4].'" tabindex="3" onkeypress=blockenter();  ><option value="01" >- -selecione- -';
      echo '	<option value="M" '.$selected_S.'>M';
      echo '	<option value="F" '.$selected_S.'>F';
      echo '</select>';
      
      echo '</br></br>';
      
      echo '<b>Endereço:<b><input type="text" name="end" value="'.$row[5].'" maxlength="35" size="35" tabindex="5" onkeypress=blockenter();  >';
      
      echo '<b>Nº.:</b><input type="text" name="num" value="'.$row[6].'" maxlength="5" size="5" tabindex="6" onkeypress=blockChars();  >';
      
      echo '<b>Complemento:<b><input type="text" name="comple" value="'.$row[7].'" maxlength="7" size="7" tabindex="7" onkeypress=blockenter();  ></b>';
      
      echo '<b>Cep.:</b><input type="text" name="cep" value="'.$row[8].'" maxlength="8" size="8" tabindex="8" onkeypress=blockChars();  >';
      
      echo '<br><br>';
      
      echo '<b>Bairro:</b><input type="text" name="bairro" value="'.$row[9].'" maxlength="20" size="20" tabindex="9" onkeypress=blockenter();  >';
      
      echo '<b>Cidade:</b><input type="text" name="cidade" value="'.$row[10].'" maxlength="20" size="20" tabindex="10" onkeypress=blockenter();  >';
      
      echo '<b>Estado:</b><input type="text" name="estado" value="'.$row[11].'" maxlength="3" size="3" tabindex="11" onkeypress=blockenter();  >';
      
      echo '<br><br>';
      
      echo '<b>CPF.:</b><input type="text" name="cpf" value="'.$row[12].'" maxlength="11" size="11" tabindex="12" onkeypress=blockChars();  >';
      
      echo '<b>RG.:</b><input type="text" name="rg" value="'.$row[13].'" maxlength="11" size="11" tabindex="13" onkeypress=blockChars();  >';
      
      echo '<b>Data Nasc.:</b><input type="text" name="datanasc" value="'.$row[14].'"  maxlength="8" size="8" tabindex="14" onkeypress=blockChars();  >';
    	
      if($row[20]=="S") $selected_S = " SELECTED"; else $selected_S = "";
      if($row[20]=="C") $selected_C = " SELECTED"; else $selected_C = "";
      if($row[20]=="V") $selected_V = " SELECTED"; else $selected_V = "";
      if($row[20]=="D") $selected_D = " SELECTED"; else $selected_D = "";
    	
      echo '<b> Estado Civil: </b><select name=estcivil value="'.$row[20].'"  tabindex="15" onkeypress=blockenter();  ><option value="01" >- -selecione- -';
      echo '        <option value="S" '.$selected_S.' >Solteiro';
      echo '        <option value="C" '.$selected_S.' >Casado';
      echo '        <option value="V" '.$selected_S.' >Viúvo';
      echo '        <option value="D" '.$selected_S.' >Divorciado</select>';
      
      echo '<br><br>';
      
      $telddd = substr($row[15], 0, 2); 
      $telres = substr($row[15], 2, 11); 
      echo '<b>DDD.:</b><input type="text" name="dddre" value = "'.$telddd.'" maxlength="2" size="2" tabindex="16" onkeypress=blockChars();  >';
      
      echo '<b>Tel. Res.:</b><input type"text" name="telres" value = "'.$telres.'" maxlength="8" size="8" tabindex="17" onkeypress=blockChars();  >';
      
      $dddcom = substr($row[16], 0, 2); 
      $telcom = substr($row[16], 2, 11); 
      echo '<b>DDD.:</b><input type="text" name="dddcom" value = "'.$dddcom.'" maxlength="2" size="2" tabindex="18"onkeypress=blockChars();  >';
      
      echo '<b>Tel. Com.:</b><input type"text" name="telcom" value = "'.$telcom.'" maxlength="8" size="8" tabindex="19"onkeypress=blockChars();  >';
      
      $dddcel = substr($row[17], 0, 2); 
      $telcel = substr($row[17], 2, 11); 
      echo '<b>DDD.:</b><input type="text" name="dddcel" value = "'.$dddcel.'" maxlength="2" size="2" tabindex="20" onkeypress=blockChars();  >';
      
      echo '<b>Tel. Cel.:</b><input type"text" name="telcel" value = "'.$telcel.'" maxlength="8" size="8" tabindex="21" onkeypress=blockChars();  >';
      
      echo '<br><br>';
      
      echo 'Profissão:<input type="text" name="profissao" value = "'.$row[18].'" maxlength="25" size="25" tabindex="22" onkeypress=blockenter();  >'; 
      echo '<br><br>';
      
      //echo '<input type="submit" name="submitcd" value="Gravar" tabindex="25" >';
      echo '</table>';
      //echo '</form>';
      echo '</body>';
      
    	}
        mysql_free_result($result);
    }

    $result_dep = mysql_query("select *from tab_dep where nomedp = '$nome'") or die ("Erro " .mysql_error());
    $num_rows_dep = mysql_num_rows($result_dep);
    if(!$result_dep){
    	echo 'NÃO POSSIVEL FAZER A CONSULTA';
    }	
    if($num_rows_dep < 1){
    	//echo 'DEPENDENTE NÃO ENCONTRADO';
    }else{
    	echo '<br><br>';
    	echo '<table>';
    	echo '<h3>DEPENDENTES</h3>';
    	while ($row = mysql_fetch_array($result_dep)) {
    
      echo '<br><br>';
      //echo '<form name="formfisi" method="post" action="deeeep.php">'; 
      echo '<b>Codigo do Cliente:</b><input type="text" name="cod_dp" value = "'.$row[0].'" maxlength="8" size="8" tabindex="1" onkeypress=blockenter();  >';
      echo '<br><br>';
      echo '<b>Nome:</b><input type="text" name="nomedp" value = "'.$row[1].'" maxlength="50" size="50" tabindex="3" onkeypress=blockenter();  >';
      echo '<br><br>';
      echo '<b>Data Nasc.:</b><input type="text" name="datanascdp" value = "'.$row[2].'" maxlength="8" size="8" tabindex="4" onkeypress="blockChars();"  >';
      
      if($row[3]=="m") $selected_M = " SELECTED"; else $selected_S = "";
      if($row[3]=="f") $selected_F = " SELECTED"; else $selected_C = "";
      echo '<b> Sexo:</b><select name="sexo" tabindex="5" onkeypress=blockenter();  ><option value="01" >- -selecione- -';
      echo '	<option value="M" '.$selected_M.' >M';
      echo '	<option value="F" '.$selected_F.' >F</select>';
      
      echo '<br><br><b>CPF.:</b><input type="text" name="cpfdp" value = "'.$row[4].'" maxlength="11" size="11" tabindex="6" onkeypress="blockChars();"  >';
      echo '<b>RG.:</b><input type="text" name="rgdp" value = "'.$row[5].'" maxlength="11" size="11" tabindex="7" onkeypress="blockChars();"  >';
      echo '<br><br>';
      //echo '<input type="submit" name="gravardp" value="Gravar" tabindex="8" >';
      //echo '</form>';
      echo '</body>';
    	}
    	echo '</table>';


        mysql_free_result($result_dep);
    }
    $result = mysql_query("select *from tab_emp where rsocial = '$nome'") or die ("Erro " .mysql_error());
    $num_rows = mysql_num_rows($result);
  
    if(!$result){
    	echo 'NÃO POSSIVEL FAZER A CONSULTA';
    }	
    
    if($num_rows < 1){
    	//echo 'CODIGO NÃO ENCONTRADO';
    }else{
    	echo '<center><h2>ALTERAÇÃO DE CLIENTE</h2></center>';
    	echo '<br><br>';
    	echo '<table border=3>';
    	
    	while ($row = mysql_fetch_array($result)) {

      echo '<body background="C:\www\cassia\imagens\background.png">';
      
      //echo '<form name="formemp" method="post" action="grava_cli_empdb.php">'; 
      

      echo '<b>Código da Empresa:</b><input type="text" name="cod_emp" value = "'.$row[0].'" maxlength="10" size="10" tabindex="1" onkeypress=blockenter();  >';
      echo '<br><br>';
      echo '<b>Razão Social:</b><input type="text" name="rsocial" value = "'.$row[1].'" maxlength="50" size="50" tabindex="2" onkeypress=blockenter();  >';
      echo '<br><br>';
      echo '<b>CNPJ.:</b><input type="text" name="cnpj" value = "'.$row[2].'" maxlength="16" size="16" tabindex="3" onkeypress=blockenter();  ><i><b>12345678 / 1234 - 12</b></i>';
      echo '<br><br>';
      echo '<b>Endereço:</b><input type="text" name="endemp" value = "'.$row[3].'" maxlength="35" size="35" tabindex="4" onkeypress=blockenter();  >';
      echo '<b>Nº.:</b><input type="text" name="numemp" value = "'.$row[4].'" maxlength="5" size="5" tabindex="5" onkeypress="blockChars();"  >';
      echo '<b>Complemento:</b><input type="text" value = "'.$row[5].'" name="compleemp" maxlength="7" size="7" tabindex="6" onkeypress=blockenter();  >';
      echo '<b> Cep.:</b><input type="text" name="cepemp" value = "'.$row[6].'" maxlength="8" size="8" tabindex="7" onkeypress="blockChars();"  >';
      echo '<br><br>';
      echo '<b> Bairro:</b><input type="text" name="bairroemp" value = "'.$row[7].'"  maxlength="20" size="20" tabindex="8" onkeypress=blockenter();  >';
      echo '<b> Cidade:</b><input type="text" name="cidadeemp" value = "'.$row[8].'" maxlength="20" size="20" tabindex="9" onkeypress=blockenter();  >';
      echo '<b> Estado:</b><input type="text" name="estadoemp" value = "'.$row[9].'" maxlength="3" size="3" tabindex="10" onkeypress=blockenter();  >';
    	
      $dddemp = substr($row[10], 0, 2); 
      $telemp = substr($row[10], 2, 11); 
      echo '<br><br>'; 
      echo '<b>DDD.:</b><input type="text" name="dddemp" value = "'.$dddemp.'" maxlength="2" size="2" tabindex="11" onkeypress="blockChars();"  >';
      echo '<b>TEL.:</b><input type="text" name="telemp" value = "'.$telemp.'" maxlength="8" size="8" tabindex="12" onkeypress="blockChars();"  >';
      echo '<b> Contato(responsável):</b><input type="text" name="contatoemp" value = "'.$row[11].'" maxlength="20" size="20" tabindex="13" onkeypress=blockenter();  >';
      echo '<br><br>';
      //echo '<input type="submit" name="gravaremp" value="Gravar" tabindex="14">';
      //echo '</form>';
      echo '</body>';
    	}
      echo '</table>';
    }
    
    $result_dep = mysql_query("select *from tab_depemp where nome_dpemp = '$nome'") or die ("Erro " .mysql_error());
    $num_rows_dep = mysql_num_rows($result_dep);
    if(!$result_dep){
    	echo 'NÃO POSSIVEL FAZER A CONSULTA';
    }	
    if($num_rows_dep < 1){
    	//echo 'DEPENDENTE NÃO ENCONTRADO';
    }else{
    	echo '<br><br>';
    	echo '<table border=3>';
    	echo '<h3>DEPENDENTES</h3>';
    	while ($row = mysql_fetch_array($result_dep)) {
  
      //echo '<form name="formfisi" method="post" action="grava_dep.php">'; 
      echo '<br>';
      echo '<b>Codigo Empresa:</b><input type="text" name="cod_emp" value = "'.$row[0].'" maxlength="10" size="10" tabindex="1" onkeypress=blockenter();>';
      echo '<br><br>';
      echo '<b>Codigo Cliente:</b><input type="text" name="cod_cli" value = "'.$row[8].'" maxlength="8" size="8" tabindex="2" onkeypress=blockenter();>';
      echo '<br><br>';
      echo '<b>Nome:</b><input type="text" name="nomedp" value = "'.$row[1].'" maxlength="50" size="50" tabindex="3" onkeypress=blockenter();>';
      echo '<br><br>';
      echo '<b>Data Nasc.:</b><input type="text" name="datanascdp" value = "'.$row[2].'" maxlength="8" size="8" tabindex="4" onkeypress=blockChars()>';
    
      if($row[3]=="M") $selected_M = " SELECTED"; else $selected_S = "";
      if($row[3]=="F") $selected_F = " SELECTED"; else $selected_C = "";
      echo '<b> Sexo:</b><select name="sexo" tabindex="5"  onkeypress=blockenter();><option value="01" >- -selecione- -';
      echo '	<option value="M" '.$selected_M.' >M';
      echo '	<option value="F" '.$selected_F.' >F</select>';
      echo '<br><br><b>CPF.:</b><input type="text" name="cpfdp" value = "'.$row[4].'" maxlength="11" size="11" tabindex="6" onkeypress=blockChars()>';
      echo '<b>RG.:</b><input type="text" name="rgdp" value = "'.$row[5].'" maxlength="11" size="11" tabindex="7" onkeypress=blockChars()>';
      echo '<br><br>';
      echo '<b>Login.:</b><input type="text" name="login" value = "'.$row[7].'" size="10" tabindex="7" onkeypress=blockChars()>';
      echo '<br><br>';

      //echo '<input type="submit" name="gravardp" value="Gravar" tabindex="8" >';
      //echo '</form>';
      echo '</body>';
      
    	}
    }
  	}
  	

Tem outras opções mas essa já dá pra ter uma noção

Obrigado

Share this post


Link to post
Share on other sites
  • 0

Com certeza deve estar dando erro, pois eu não coloquei o script inteiro, coloquei só a primeirac parte, só pra vocês terem uma noção...

Mas se você quizer eu coloco o script inteiro...

Até mais

Share this post


Link to post
Share on other sites
  • 0

Vou mandar todo, por favor Junte com a primeira parte

Até mais

if($rg!=''){
    $result = mysql_query("select *from tab_cli where rg = '$rg'") or die ("Erro " .mysql_error());
    $num_rows = mysql_num_rows($result);
  
    if(!$result){
    	echo 'NÃO POSSIVEL FAZER A CONSULTA';
    }	
    
    if($num_rows < 1){
    	//echo 'CODIGO NÃO ENCONTRADO';
    }else{
    	//echo '<form>';
    	echo '<center><h2>ALTERAÇÃO DE CLIENTE</h2></center>';
    	echo '<br><br>';
    	echo '<table border=3>';
    	while ($row = mysql_fetch_array($result)) {

      //echo '<body >';
      
      //echo '<form method="post" action="fissssssssi.php" name="form1" >';
      
      echo'<b>Codigo do Titular:</b>';
      
      echo '<input type="text" name="cod_titu" value="'.$row[2].'" maxlength="8" size="8" tabindex="1" onkeypress=blockenter();  >';
      echo '<br><br>';
      
      echo '<b>Nome:</b><input type=text name="nome" maxlength="50" value="'.$row[3].'" size="50" tabindex="2"  >';
    	
      if($row[4]=="M") $selected_S = " SELECTED"; else $selected_S = "";
      if($row[4]=="F") $selected_C = " SELECTED"; else $selected_C = "";
    	
      echo '<b> Sexo:</b><select name="sexo" value="'.$row[4].'" tabindex="3" onkeypress=blockenter();  ><option value="01" >- -selecione- -';
      echo '	<option value="M" '.$selected_S.'>M';
      echo '	<option value="F" '.$selected_S.'>F';
      echo '</select>';
      
      echo '</br></br>';
      
      echo '<b>Endereço:<b><input type="text" name="end" value="'.$row[5].'" maxlength="35" size="35" tabindex="5" onkeypress=blockenter();  >';
      
      echo '<b>Nº.:</b><input type="text" name="num" value="'.$row[6].'" maxlength="5" size="5" tabindex="6" onkeypress=blockChars();  >';
      
      echo '<b>Complemento:<b><input type="text" name="comple" value="'.$row[7].'" maxlength="7" size="7" tabindex="7" onkeypress=blockenter();  ></b>';
      
      echo '<b>Cep.:</b><input type="text" name="cep" value="'.$row[8].'" maxlength="8" size="8" tabindex="8" onkeypress=blockChars();  >';
      
      echo '<br><br>';
      
      echo '<b>Bairro:</b><input type="text" name="bairro" value="'.$row[9].'" maxlength="20" size="20" tabindex="9" onkeypress=blockenter();  >';
      
      echo '<b>Cidade:</b><input type="text" name="cidade" value="'.$row[10].'" maxlength="20" size="20" tabindex="10" onkeypress=blockenter();  >';
      
      echo '<b>Estado:</b><input type="text" name="estado" value="'.$row[11].'" maxlength="3" size="3" tabindex="11" onkeypress=blockenter();  >';
      
      echo '<br><br>';
      
      echo '<b>CPF.:</b><input type="text" name="cpf" value="'.$row[12].'" maxlength="11" size="11" tabindex="12" onkeypress=blockChars();  >';
      
      echo '<b>RG.:</b><input type="text" name="rg" value="'.$row[13].'" maxlength="11" size="11" tabindex="13" onkeypress=blockChars();  >';
      
      echo '<b>Data Nasc.:</b><input type="text" name="datanasc" value="'.$row[14].'"  maxlength="8" size="8" tabindex="14" onkeypress=blockChars();  >';
    	
      if($row[20]=="S") $selected_S = " SELECTED"; else $selected_S = "";
      if($row[20]=="C") $selected_C = " SELECTED"; else $selected_C = "";
      if($row[20]=="V") $selected_V = " SELECTED"; else $selected_V = "";
      if($row[20]=="D") $selected_D = " SELECTED"; else $selected_D = "";
    	
      echo '<b> Estado Civil: </b><select name=estcivil value="'.$row[20].'"  tabindex="15" onkeypress=blockenter();  ><option value="01" >- -selecione- -';
      echo '        <option value="S" '.$selected_S.' >Solteiro';
      echo '        <option value="C" '.$selected_S.' >Casado';
      echo '        <option value="V" '.$selected_S.' >Viúvo';
      echo '        <option value="D" '.$selected_S.' >Divorciado</select>';
      
      echo '<br><br>';
      
      $telddd = substr($row[15], 0, 2); 
      $telres = substr($row[15], 2, 11); 
      echo '<b>DDD.:</b><input type="text" name="dddre" value = "'.$telddd.'" maxlength="2" size="2" tabindex="16" onkeypress=blockChars();  >';
      
      echo '<b>Tel. Res.:</b><input type"text" name="telres" value = "'.$telres.'" maxlength="8" size="8" tabindex="17" onkeypress=blockChars();  >';
      
      $dddcom = substr($row[16], 0, 2); 
      $telcom = substr($row[16], 2, 11); 
      echo '<b>DDD.:</b><input type="text" name="dddcom" value = "'.$dddcom.'" maxlength="2" size="2" tabindex="18"onkeypress=blockChars();  >';
      
      echo '<b>Tel. Com.:</b><input type"text" name="telcom" value = "'.$telcom.'" maxlength="8" size="8" tabindex="19"onkeypress=blockChars();  >';
      
      $dddcel = substr($row[17], 0, 2); 
      $telcel = substr($row[17], 2, 11); 
      echo '<b>DDD.:</b><input type="text" name="dddcel" value = "'.$dddcel.'" maxlength="2" size="2" tabindex="20" onkeypress=blockChars();  >';
      
      echo '<b>Tel. Cel.:</b><input type"text" name="telcel" value = "'.$telcel.'" maxlength="8" size="8" tabindex="21" onkeypress=blockChars();  >';
      
      echo '<br><br>';
      
      echo 'Profissão:<input type="text" name="profissao" value = "'.$row[18].'" maxlength="25" size="25" tabindex="22" onkeypress=blockenter();  >'; 
      echo '<br><br>';
      
      //echo '<input type="submit" name="submitcd" value="Gravar" tabindex="25" >';
      echo '</table>';
      //echo '</form>';
      echo '</body>';
      
    	}
        mysql_free_result($result);
    }

    $result_dep = mysql_query("select *from tab_dep where rgdp = '$rg'") or die ("Erro " .mysql_error());
    $num_rows_dep = mysql_num_rows($result_dep);
    if(!$result_dep){
    	echo 'NÃO POSSIVEL FAZER A CONSULTA';
    }	
    if($num_rows_dep < 1){
    	//echo 'DEPENDENTE NÃO ENCONTRADO';
    }else{
    	echo '<br><br>';
    	echo '<table>';
    	echo '<h3>DEPENDENTES</h3>';
    	while ($row = mysql_fetch_array($result_dep)) {
    
      echo '<br><br>';
      //echo '<form name="formfisi" method="post" action="deeeep.php">'; 
      echo '<b>Codigo do Cliente:</b><input type="text" name="cod_dp" value = "'.$row[0].'" maxlength="8" size="8" tabindex="1" onkeypress=blockenter();  >';
      echo '<br><br>';
      echo '<b>Nome:</b><input type="text" name="nomedp" value = "'.$row[1].'" maxlength="50" size="50" tabindex="3" onkeypress=blockenter();  >';
      echo '<br><br>';
      echo '<b>Data Nasc.:</b><input type="text" name="datanascdp" value = "'.$row[2].'" maxlength="8" size="8" tabindex="4" onkeypress="blockChars();"  >';
      
      if($row[3]=="m") $selected_M = " SELECTED"; else $selected_S = "";
      if($row[3]=="f") $selected_F = " SELECTED"; else $selected_C = "";
      echo '<b> Sexo:</b><select name="sexo" tabindex="5" onkeypress=blockenter();  ><option value="01" >- -selecione- -';
      echo '	<option value="M" '.$selected_M.' >M';
      echo '	<option value="F" '.$selected_F.' >F</select>';
      
      echo '<br><br><b>CPF.:</b><input type="text" name="cpfdp" value = "'.$row[4].'" maxlength="11" size="11" tabindex="6" onkeypress="blockChars();"  >';
      echo '<b>RG.:</b><input type="text" name="rgdp" value = "'.$row[5].'" maxlength="11" size="11" tabindex="7" onkeypress="blockChars();"  >';
      echo '<br><br>';
      //echo '<input type="submit" name="gravardp" value="Gravar" tabindex="8" >';
      //echo '</form>';
      echo '</body>';
    	}
    	echo '</table>';


        mysql_free_result($result_dep);
    }
        
    $result_dep = mysql_query("select *from tab_depemp where rg_dpemp = '$rg'") or die ("Erro " .mysql_error());
    $num_rows_dep = mysql_num_rows($result_dep);
    if(!$result_dep){
    	echo 'NÃO POSSIVEL FAZER A CONSULTA';
    }	
    if($num_rows_dep < 1){
    	//echo 'DEPENDENTE NÃO ENCONTRADO';
    }else{
    	echo '<br><br>';
    	echo '<table border=3>';
    	echo '<h3>DEPENDENTES</h3>';
    	while ($row = mysql_fetch_array($result_dep)) {
  
      //echo '<form name="formfisi" method="post" action="grava_dep.php">'; 
      echo '<br>';
      echo '<b>Codigo Empresa:</b><input type="text" name="cod_emp" value = "'.$row[0].'" maxlength="10" size="10" tabindex="1" onkeypress=blockenter();>';
      echo '<br><br>';
      echo '<b>Codigo Cliente:</b><input type="text" name="cod_cli" value = "'.$row[8].'" maxlength="8" size="8" tabindex="2" onkeypress=blockenter();>';
      echo '<br><br>';
      echo '<b>Nome:</b><input type="text" name="nomedp" value = "'.$row[1].'" maxlength="50" size="50" tabindex="3" onkeypress=blockenter();>';
      echo '<br><br>';
      echo '<b>Data Nasc.:</b><input type="text" name="datanascdp" value = "'.$row[2].'" maxlength="8" size="8" tabindex="4" onkeypress=blockChars()>';
    
      if($row[3]=="M") $selected_M = " SELECTED"; else $selected_S = "";
      if($row[3]=="F") $selected_F = " SELECTED"; else $selected_C = "";
      echo '<b> Sexo:</b><select name="sexo" tabindex="5"  onkeypress=blockenter();><option value="01" >- -selecione- -';
      echo '	<option value="M" '.$selected_M.' >M';
      echo '	<option value="F" '.$selected_F.' >F</select>';
      echo '<br><br><b>CPF.:</b><input type="text" name="cpfdp" value = "'.$row[4].'" maxlength="11" size="11" tabindex="6" onkeypress=blockChars()>';
      echo '<b>RG.:</b><input type="text" name="rgdp" value = "'.$row[5].'" maxlength="11" size="11" tabindex="7" onkeypress=blockChars()>';
      echo '<br><br>';
      echo '<b>Login.:</b><input type="text" name="login" value = "'.$row[7].'" size="10" tabindex="7" onkeypress=blockChars()>';
      echo '<br><br>';

      //echo '<input type="submit" name="gravardp" value="Gravar" tabindex="8" >';
      //echo '</form>';
      echo '</body>';
      
    	}
    }
  	}

if($cnpj!=''){
    $result = mysql_query("select *from tab_emp where cnpj = '$cnpj'") or die ("Erro " .mysql_error());
    $num_rows = mysql_num_rows($result);
  
    if(!$result){
    	echo 'NÃO POSSIVEL FAZER A CONSULTA';
    }	
    
    if($num_rows < 1){
    	//echo 'CODIGO NÃO ENCONTRADO';
    }else{
    	echo '<center><h2>ALTERAÇÃO DE CLIENTE</h2></center>';
    	echo '<br><br>';
    	echo '<table border=3>';
    	
    	while ($row = mysql_fetch_array($result)) {

      echo '<body background="C:\www\cassia\imagens\background.png">';
      
      //echo '<form name="formemp" method="post" action="grava_cli_empdb.php">'; 
      

      echo '<b>Código da Empresa:</b><input type="text" name="cod_emp" value = "'.$row[0].'" maxlength="10" size="10" tabindex="1" onkeypress=blockenter();  >';
      echo '<br><br>';
      echo '<b>Razão Social:</b><input type="text" name="rsocial" value = "'.$row[1].'" maxlength="50" size="50" tabindex="2" onkeypress=blockenter();  >';
      echo '<br><br>';
      echo '<b>CNPJ.:</b><input type="text" name="cnpj" value = "'.$row[2].'" maxlength="16" size="16" tabindex="3" onkeypress=blockenter();  ><i><b>12345678 / 1234 - 12</b></i>';
      echo '<br><br>';
      echo '<b>Endereço:</b><input type="text" name="endemp" value = "'.$row[3].'" maxlength="35" size="35" tabindex="4" onkeypress=blockenter();  >';
      echo '<b>Nº.:</b><input type="text" name="numemp" value = "'.$row[4].'" maxlength="5" size="5" tabindex="5" onkeypress="blockChars();"  >';
      echo '<b>Complemento:</b><input type="text" value = "'.$row[5].'" name="compleemp" maxlength="7" size="7" tabindex="6" onkeypress=blockenter();  >';
      echo '<b> Cep.:</b><input type="text" name="cepemp" value = "'.$row[6].'" maxlength="8" size="8" tabindex="7" onkeypress="blockChars();"  >';
      echo '<br><br>';
      echo '<b> Bairro:</b><input type="text" name="bairroemp" value = "'.$row[7].'"  maxlength="20" size="20" tabindex="8" onkeypress=blockenter();  >';
      echo '<b> Cidade:</b><input type="text" name="cidadeemp" value = "'.$row[8].'" maxlength="20" size="20" tabindex="9" onkeypress=blockenter();  >';
      echo '<b> Estado:</b><input type="text" name="estadoemp" value = "'.$row[9].'" maxlength="3" size="3" tabindex="10" onkeypress=blockenter();  >';
    	
      $dddemp = substr($row[10], 0, 2); 
      $telemp = substr($row[10], 2, 11); 
      echo '<br><br>'; 
      echo '<b>DDD.:</b><input type="text" name="dddemp" value = "'.$dddemp.'" maxlength="2" size="2" tabindex="11" onkeypress="blockChars();"  >';
      echo '<b>TEL.:</b><input type="text" name="telemp" value = "'.$telemp.'" maxlength="8" size="8" tabindex="12" onkeypress="blockChars();"  >';
      echo '<b> Contato(responsável):</b><input type="text" name="contatoemp" value = "'.$row[11].'" maxlength="20" size="20" tabindex="13" onkeypress=blockenter();  >';
      echo '<br><br>';
      //echo '<input type="submit" name="gravaremp" value="Gravar" tabindex="14">';
      //echo '</form>';
      echo '</body>';
    	}
      echo '</table>';
    }
  	}

  	echo '<input type="submit" name="salvar" value="Gravar" tabindex="14">';
  	echo '</form>';
  }
	}

?>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  



  • Forum Statistics

    • Total Topics
      148104
    • Total Posts
      643372
×
×
  • Create New...