for loop question
Ok, I'm writing a script that reads out values from a text file and prints 5 per row. What I've currently got:
currently just loops the first set of 5 records returned based on the number of rows used. Is there a way for this to actually return the proper results with the right loopthrough (e.g. 2nd runthrough by for() returns the 2nd set of 5 results)?
EDIT: Solved;
fixed everything. Thanks
olithered!
$patches = array(); while(!feof($fp)): $patch = fgetcsv($fp, 4096); for ($i = 0; $i < 1; $i++): $patches[] = $patch[0]; endfor; endwhile; // let's now loop for every 5 records $numpatch = count($patches); $numpatch = ceil($numpatch/5); for ($i = 0; $i < $numpatch; $i++): print "<tr colspan=\"5\">"; for ($a = 0; $a < 5; $a++): echo "<td>$patches[$a]</td>"; endfor; print "</tr>"; endfor;
currently just loops the first set of 5 records returned based on the number of rows used. Is there a way for this to actually return the proper results with the right loopthrough (e.g. 2nd runthrough by for() returns the 2nd set of 5 results)?
EDIT: Solved;
for ($a = 0; $a < 5; $a++): $num = $i*5+$a; echo "<td>$patches[$num]</td>"; endfor;
fixed everything. Thanks
