+/-
codice:
<?php
$conn = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
$sql = "SELECT * FROM tabella";
$rs = mysql_query($sql) or die(mysql_error());
$a = 0;
$b = 1;
$c = 1;
while ($row = mysql_fetch_array($rs)) {
$file = 'file' . $c . '.txt';
if ($a % 5 == 0) {
$b = 1;
if (isset($h)) {
fclose($h);
}
$h = fopen($file, 'w');
$c++;
}
$text = '&primo' . $b . '=' . $row[0] . '&secondo' . $b . '=' . $row[1] ."\r\n";
fwrite($h, $text);
$a++;
$b++;
}
fclose($h);
echo 'finished';
?>