ARCHIVO PHP
Código PHP :
if (isset( $_POST['submit'] )) {
$numero_afiliado = ($_POST['numeroafiliado']);
include( 'conexion/conexion-abrir.php' );
#Extraer todas las filas primer nivel
$datosnivel1 = array();
$datosnivel2 = array();
$cantidaddatosdentrodelarreglo = array();
$consulta = "SELECT IDAfiliado FROM DatosAfiliados WHERE IDPadrino='$numero_afiliado'";
$resultado = $conexion -> query($consulta);
while($fila = $resultado -> fetch_array())
{
$datosnivel1[] = $fila["IDAfiliado"];
}
$cuentaregistrosdatosnivel1 = count($datosnivel1);
echo "El afiliado no. $numero_afiliado tiene $cuentaregistrosdatosnivel1 afiliados en este primer nivel.<br>";
echo "<pre>";
print_r($datosnivel1);
echo "</pre>";
echo "<br>Empiezo a buscar el nivel 2:<br><br>";
for($i = 0; $i < count($datosnivel1); ++$i)
{
$consulta = "SELECT IDAfiliado FROM DatosAfiliados WHERE IDPadrino=$datosnivel1[$i]";
$resultado = $conexion -> query($consulta);
while($fila = $resultado -> fetch_array())
{
$datosnivel2[$i][] = $fila["IDAfiliado"];
}
echo "En este segundo nivel, si acaso existen, para el afiliado " . $datosnivel1[$i] . " tenemos " . count($datosnivel2[$i]) . " subafiliados.<br>";
[i][b]$cantidaddatosdentrodelarreglo[$i] = count($datosnivel2[$i]); /////LINEA 33
echo "<pre>"; /////LINEA 34
print_r($datosnivel2[$i]);
echo "</pre>"; ///// LINEA 36[/b][/i]
}
echo "<br>Tenemos " . array_sum($cantidaddatosdentrodelarreglo) ." subafiliados en total en este nivel 2. <br>";
include('conexion/conexion-cerrar.php' );
}
<html>
<head>
<title>Encontrando Afiliados en los Niveles Inferiores</title>
<meta name="content" content="text/html;" http-equiv="content-type" charset="utf-8">
</head>
<body>
<p style="font-size:32px; text-align:center">Encontrando Afiliados en los Niveles Inferiores, a partir del # Afiliado:</p><br>
<form action="hasta2nivel.php" method="post">
<p>No. Afiliado :</p> <input name="numeroafiliado" type="text">
<input type="submit" name="submit" value="¡Enviarme!" /><br>
</form><br>
</body>
</html>
MENSAJE LOG DE ERROR
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 1 in /home/globwsy/public_html/portal/hasta2nivel.php on line 33
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 1 in /home/globwsy/public_html/portal/hasta2nivel.php on line 34
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 1 in /home/globwsy/public_html/portal/hasta2nivel.php on line 36
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 2 in /home/globwsy/public_html/portal/hasta2nivel.php on line 33
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 2 in /home/globwsy/public_html/portal/hasta2nivel.php on line 34
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 2 in /home/globwsy/public_html/portal/hasta2nivel.php on line 36
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 3 in /home/globwsy/public_html/portal/hasta2nivel.php on line 33
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 3 in /home/globwsy/public_html/portal/hasta2nivel.php on line 34
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 3 in /home/globwsy/public_html/portal/hasta2nivel.php on line 36
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 4 in /home/globwsy/public_html/portal/hasta2nivel.php on line 33
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 4 in /home/globwsy/public_html/portal/hasta2nivel.php on line 34
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 4 in /home/globwsy/public_html/portal/hasta2nivel.php on line 36
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 5 in /home/globwsy/public_html/portal/hasta2nivel.php on line 33
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 5 in /home/globwsy/public_html/portal/hasta2nivel.php on line 34
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 5 in /home/globwsy/public_html/portal/hasta2nivel.php on line 36
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 6 in /home/globwsy/public_html/portal/hasta2nivel.php on line 33
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 6 in /home/globwsy/public_html/portal/hasta2nivel.php on line 34
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 6 in /home/globwsy/public_html/portal/hasta2nivel.php on line 36
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 7 in /home/globwsy/public_html/portal/hasta2nivel.php on line 33
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 7 in /home/globwsy/public_html/portal/hasta2nivel.php on line 34
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 7 in /home/globwsy/public_html/portal/hasta2nivel.php on line 36
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 8 in /home/globwsy/public_html/portal/hasta2nivel.php on line 33
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 8 in /home/globwsy/public_html/portal/hasta2nivel.php on line 34
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 8 in /home/globwsy/public_html/portal/hasta2nivel.php on line 36
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 9 in /home/globwsy/public_html/portal/hasta2nivel.php on line 33
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 9 in /home/globwsy/public_html/portal/hasta2nivel.php on line 34
[28-May-2017 06:00:40 Etc/GMT] PHP Notice: Undefined offset: 9 in /home/globwsy/public_html/portal/hasta2nivel.php on line 36
NOTAS:
