<?php
 
session_start();
include("DMMYSQLG.php");
$com = "C";
include("DSA3000.php");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<?php

if ($_POST['bot']==""){
	echo '<h2>!!! SELECCIONA UN REGISTRO... ACTUALIZANDO !!!</h2>';
	echo '<meta content="1; url=DX23000_PR.php"  HTTP-EQUIV="REFRESH">';
}else{
	include('DX21000_CL.php');
	$varible_clase = new clase_paises();
	$res=$varible_clase->lista_busqueda($_POST["bot"]);
	$reg=mysqli_fetch_array($res);
?>
<body
<?php
 
if(isset($_POST['bot3'])){
	echo ' onLoad="deshab()"';
}
?>
>
<form  name="frm1" method="post" action="">
<input name="bot" type="hidden" 
<?php
 
if(isset($_POST['bot'])){ 
	echo 'value="' . $_POST['bot'] .  '"';
}else{
	  echo 'value="' . $reg['llave'] .  '"';
}
?>
>
  <table width="400"  align="center">
    <tr>
      <th colspan="2" class=\"titulo\"><div align="center">DELEGACION / MUNICIPIO </div></th>
    </tr>
    <tr>
      <td>Pais:</td>
      <td><select name="paises1" onChange="javascript: document.getElementById('frm1').submit()">
  <?php
 
$sqd=mysqli_query($con ,"select * from dxdelmun where cve_delmun='".$_POST['bot']."'");
$red=mysqli_fetch_array($sqd);

if (isset($_REQUEST['paises1'])){
	$p = $_REQUEST['paises1'];
}else{
	$p = $red['cve_pais'];
}
   
$sql1 = mysqli_query($con ,"SELECT * FROM dxpaises");
while($row=mysqli_fetch_array($sql1)){
	if($row['cve_pais'] == $p){
		echo '<option value="' . $row['cve_pais'] . '" selected>' . $row['des_pais'].'</option>';
	}else{
		echo '<option value="' . $row['cve_pais'] . '">' . $row['des_pais'].'</option>';
	}
}  
  
  
  
  
/*if(isset($_POST['paises1'])){ 
	@$sql=mysqli_query($con ,"select * from dxpaises where cve_pais='".$_POST['paises1']."'");
	$reg1=mysqli_fetch_array($sql);
	echo '<option value="'. $reg1['cve_pais'] .'">'.$reg1['des_pais'].'</option>';
}elseif(isset($_POST['bot'])){ 
	//conocer el numero de pais
	@$sql=mysqli_query($con ,"select * from dxdelmun where cve_delmun='".$_POST['bot']."'");
	$reg=mysqli_fetch_array($sql);
	//buscar le pais
	@$sql=mysqli_query($con ,"select * from dxpaises where cve_pais='$reg['cve_pais'].'");
	$reg1=mysqli_fetch_array($sql);
	echo '<option value="'. $reg1['cve_pais'] .'">'.$reg1['des_pais'].'</option>';
}
@$sql=mysqli_query($con ,"select * from dxpaises");
while($reg1=mysqli_fetch_array($sql)){
	echo '<option value="' . $reg1['cve_pais'] . '">' . $reg1['des_pais'] . '</option>';
}	*/		
?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Estado:</td>
      <td><select name="estados">
          <?php

//echo $red['cve_estado'];

/* $sql12 = mysqli_query($con ,"SELECT * FROM dxestado");
while($row2=mysqli_fetch_array($sql12)){
	if($row2['cve_estado'] == $red['cve_estado']){
		echo '<option value="' . $row2['cve_estado'] . '" selected>' . $row2['des_estado'].'</option>';
	}else{
		echo '<option value="' . $row2['cve_estado'] . '">' . $row2['des_estado'].'</option>';
	}
}  
 */
if(isset($_POST['paises1'])){ 
	@$sql=mysqli_query($con ,"select * from dxestado where cve_pais='".$_POST['paises1']."'");
	$es = $_POST['estados'];
}else{
	@$sql=mysqli_query($con ,"select * from dxestado where cve_pais='".$red['cve_pais']."'");
	$es = $red['cve_estado'];
}
	while($reg1=mysqli_fetch_array($sql)){
		if($reg1['cve_estado'] == $es){
			echo '<option value="' . $reg1['cve_estado'] . '" selected>' . $reg1['des_estado'] . '</option>';
		}else{
			echo '<option value="' . $reg1['cve_estado'] . '">' . $reg1['des_estado'] . '</option>';
		}
	}


?>
        </select>
      </td>
    </tr>
    <tr>
      <td width="108">Delegacion / Municipio: </td>
      <td width="384">
	  <input name="tmun" type="text"  size="45"
<?php
 
echo '<option value="'. $red['des_delmun'] .'"';
?>
	  ></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
    </tr>
  </table>
</form>
<?php
 
if(isset($_POST['bot3'])){
	echo '<div align="center">
	<form id="form1" name="form1" action="DX23000_PR.php" target="_self">
		<input type="submit" name="submit" value="Regresar">
	</form>
	</div>';
	
}
?>
</body>
<?php
 
mysqli_close($con);
}
?>
</html>