I am pretty sure that you can put a while loop inside of a while loop, as i have done it before, but i seem to be running into a problem here. As this is pretty complex, ill post my code then explain it.
PHP:
//post vars
$port=$_POST['ports'];
$super=$_POST['super'];
$col=$_POST['columns'];
$row=$_POST['rows'];
//rest of vars
$half_col=$col/$super;
$halfer_col=$col/$super;
$i=1;
$count=1;
$and=1;
$one=1;
$sector=array();
$dat_array=array();
echo $port."<br>";
echo $super."<br>";
echo $col."<br>";
echo $row."<br><br><br><br>";
echo "<h1>here goes nothen</h1><br><br>";
while($count<$port){
while($i<=$half_col){
$dat_array[]=$halfer_col;
$i+=$and;
$halfer_col-=$and;
echo "<br>halfer_col:".$halfer_col."<br>";
}
print_r($dat_array);
$sector[]=implode(',',$dat_array);
$count+=$half_col;
$halfer_col+=$half_col;
}
echo "<br><br>ANNNNNNND...<br><br>";
print_r($sector);
Now, this is with user input port:24 super:2 col:12 row:2 result:
24
2
12
2
here goes nothen
halfer_col:5
halfer_col:4
halfer_col:3
halfer_col:2
halfer_col:1
halfer_col:0
Array ( [0] => 6 [1] => 5 [2] => 4 [3] => 3 [4] => 2 [5] => 1 ) Array ( [0] => 6 [1] => 5 [2] => 4 [3] => 3 [4] => 2 [5] => 1 ) Array ( [0] => 6 [1] => 5 [2] => 4 [3] => 3 [4] => 2 [5] => 1 ) Array ( [0] => 6 [1] => 5 [2] => 4 [3] => 3 [4] => 2 [5] => 1 )
ANNNNNNND...
Array ( [0] => 6,5,4,3,2,1 [1] => 6,5,4,3,2,1 [2] => 6,5,4,3,2,1 [3] => 6,5,4,3,2,1 )
basically, it takes the user input, breaks it down and implodes it in the prober order based on a ",". however from what i can tell, it is not adding here: $halfer_col+=$half_col; and that is causing the data to not increment, any ideas anyone? Or even an explanation as to why that will not add and affect my internal while loop the way that it is set.
in the end the final array should look like so:
Array ( [0] => 6,5,4,3,2,1 [1] => 12,11,10,9,8,7 [2] => 18,17,16,15,14,13 [3] => 24,23,22,21,20,19 )