Ver Mensaje Individual
  #9 (permalink)  
Antiguo 18/01/2012, 18:38
wayward
(Desactivado)
 
Fecha de Ingreso: enero-2004
Mensajes: 136
Antigüedad: 20 años, 3 meses
Puntos: 0
Respuesta: Combobox problema

Este es el codigo.

Y el Undifinied Index da en la linea 77 , 89 y 104

Código PHP:
Ver original
  1. <?php require_once('Connections/aluxbd.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34.  
  35.  
  36. mysql_select_db($database_aluxbd, $aluxbd);
  37. $query_ID_AUTONOMIA = "SELECT * FROM autonomia";
  38. $ID_AUTONOMIA = mysql_query($query_ID_AUTONOMIA, $aluxbd) or die(mysql_error());
  39. $row_ID_AUTONOMIA = mysql_fetch_assoc($ID_AUTONOMIA);
  40. $totalRows_ID_AUTONOMIA = mysql_num_rows($ID_AUTONOMIA);
  41.  
  42. $colname_prov = "-1";
  43. if (isset($_POST['ID_AUTONOMIA'])) {
  44.   $colname_prov = $_POST['ID_AUTONOMIA'];
  45. }
  46. mysql_select_db($database_aluxbd, $aluxbd);
  47. $query_prov = sprintf("SELECT * FROM provincia WHERE ID_AUTONOMIA = %s", GetSQLValueString($colname_prov, "int"));
  48. $prov = mysql_query($query_prov, $aluxbd) or die(mysql_error());
  49. $row_prov = mysql_fetch_assoc($prov);
  50. $totalRows_prov = mysql_num_rows($prov);
  51.  
  52. $colname_poblacion = "-1";
  53. if (isset($_POST['ID_PROVINCIA'])) {
  54.   $colname_poblacion = $_POST['ID_PROVINCIA'];
  55. }
  56. mysql_select_db($database_aluxbd, $aluxbd);
  57. $query_poblacion = sprintf("SELECT * FROM poblacion WHERE ID_PROVINCIA = %s", GetSQLValueString($colname_poblacion, "int"));
  58. $poblacion = mysql_query($query_poblacion, $aluxbd) or die(mysql_error());
  59. $row_poblacion = mysql_fetch_assoc($poblacion);
  60. $totalRows_poblacion = mysql_num_rows($poblacion);
  61. ?>
  62. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  63. <html xmlns="http://www.w3.org/1999/xhtml">
  64. <head>
  65. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  66. <title>Combobox</title>
  67. </head>
  68.  
  69. <body>
  70. <form action="" method="post" enctype="application/x-www-form-urlencoded" name="combo" id="combo">
  71.   <label for="ID_AUTONOMIA"></label>
  72.   <select name="ID_AUTONOMIA" id="ID_AUTONOMIA" onChange="submit()">
  73.     <option value="">Autonomia</option>
  74.     <?php
  75. do {  
  76. ?>
  77. <option value="<?php echo $row_ID_AUTONOMIA['ID_AUTONOMIA']?>"<?php if (!(strcmp($row_ID_AUTONOMIA['ID_AUTONOMIA'], $_POST['ID_AUTONOMIA']))) {echo "selected=\"selected\"";} ?>><?php echo $row_ID_AUTONOMIA['AUTONOMIA']?></option>
  78.     <?php
  79. } while ($row_ID_AUTONOMIA = mysql_fetch_assoc($ID_AUTONOMIA));
  80.   $rows = mysql_num_rows($ID_AUTONOMIA);
  81.   if($rows > 0) {
  82.       mysql_data_seek($ID_AUTONOMIA, 0);
  83.       $row_ID_AUTONOMIA = mysql_fetch_assoc($ID_AUTONOMIA);
  84.   }
  85. ?>
  86.   </select>
  87.   <label for="ID_PROVINCIA"></label>
  88.   <select name="ID_PROVINCIA" id="ID_PROVINCIA" onChange="submit()">
  89.     <option value="" <?php if (!(strcmp("", $_POST['ID_PROVINCIA']))) {echo "selected=\"selected\"";} ?>>Provincia</option>
  90.     <?php
  91. do {  
  92. ?>
  93.     <option value="<?php echo $row_prov['ID_PROVINCIA']?>"<?php if (!(strcmp($row_prov['ID_PROVINCIA'], $_POST['ID_PROVINCIA']))) {echo "selected=\"selected\"";} ?>><?php echo $row_prov['PROVINCIA']?></option>
  94.     <?php
  95. } while ($row_prov = mysql_fetch_assoc($prov));
  96.   $rows = mysql_num_rows($prov);
  97.   if($rows > 0) {
  98.       mysql_data_seek($prov, 0);
  99.       $row_prov = mysql_fetch_assoc($prov);
  100.   }
  101. ?>
  102.   </select>
  103.   <select name="ID_CIUDAD" id="ID_CIUDAD">
  104.     <option value="" <?php if (!(strcmp("", $_POST['ID_CIUDAD']))) {echo "selected=\"selected\"";} ?>>Poblacion</option>
  105.     <?php
  106. do {  
  107. ?>
  108.     <option value="<?php echo $row_poblacion['ID_CIUDAD']?>"<?php if (!(strcmp($row_poblacion['ID_CIUDAD'], $_POST['ID_CIUDAD']))) {echo "selected=\"selected\"";} ?>><?php echo $row_poblacion['CIUDAD']?></option>
  109.     <?php
  110. } while ($row_poblacion = mysql_fetch_assoc($poblacion));
  111.   $rows = mysql_num_rows($poblacion);
  112.   if($rows > 0) {
  113.       mysql_data_seek($poblacion, 0);
  114.       $row_poblacion = mysql_fetch_assoc($poblacion);
  115.   }
  116. ?>
  117.   </select>
  118. </form>
  119. </body>
  120. </html>
  121. <?php
  122. mysql_free_result($ID_AUTONOMIA);
  123.  
  124.  
  125. mysql_free_result($poblacion);
  126. ?>