hola tengo un problema quiero crear list dependientes uno de otro
creo un juego de registros para cada list probe los list por si solos pero no me funcionan cuando los uno con un list en forma dinamica me podrian ayudar este es codigo que tengo
en vista codigo
<?php require_once('Connections/.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_saticweb, $saticweb);
$query_region = "SELECT * FROM region";
$region = mysql_query($query_region, $saticweb) or die(mysql_error());
$row_region = mysql_fetch_assoc($region);
$totalRows_region = mysql_num_rows($region);
$colname_distrito = "-1";
if (isset($_GET['id_region'])) {
$colname_distrito = $_GET['id_region'];
}
mysql_select_db($database_saticweb, $saticweb);
$query_distrito = sprintf("SELECT Id_distrito, nombre FROM distrito WHERE id_region = %s", GetSQLValueString($colname_distrito, "int"));
$distrito = mysql_query($query_distrito, $saticweb) or die(mysql_error());
$row_distrito = mysql_fetch_assoc($distrito);
$totalRows_distrito = mysql_num_rows($distrito);
?>
<label></label>
<p>
<?php
mysql_free_result($region);
mysql_free_result($distrito);
?>
</p>
<form name="form1" method="post" action="">
<label>
<select name="region" id="region">
<?php
do {
?>
<option value="<?php echo $row_region['id_region']?>"<?php if (!(strcmp($row_region['id_region'], $row_region['region']))) {echo "selected=\"selected\"";} ?>><?php echo $row_region['region']?></option>
<?php
} while ($row_region = mysql_fetch_assoc($region));
$rows = mysql_num_rows($region);
if($rows > 0) {
mysql_data_seek($region, 0);
$row_region = mysql_fetch_assoc($region);
}
?>
</select>
</label>
<p> </p>
<label>
<select name="distrito" id="distrito">
<?php
do {
?>
<option value="<?php echo $row_distrito['Id_distrito']?>"<?php if (!(strcmp($row_distrito['Id_distrito'], $row_distrito['Id_distrito']))) {echo "selected=\"selected\"";} ?>><?php echo $row_distrito['nombre']?></option>
<?php
} while ($row_distrito = mysql_fetch_assoc($distrito));
$rows = mysql_num_rows($distrito);
if($rows > 0) {
mysql_data_seek($distrito, 0);
$row_distrito = mysql_fetch_assoc($distrito);
}
?>
</select>
</label>
</form>
<p> </p>