Hola antes que nada y espero que puedan ayudarme, ya que de PHP ando más bien tieso.
Tengo el siguiente código que me permite llamar línea a linea o bien a toda la base de datos que tengo almacenada en un txt, y lo que me guustaría saber es si hay alguna forma de llamarla de cinco en cinco registros y que se generen los enlaces automáticamente dependiendo del número de entradas.
Gracias por adelantado.
Código PHP:
<?php
$size=filesize("compra.txt");
if (!$size =="0") {
$fp = fopen("compra.txt","r");
$line = 0;
while (!feof ($fp) )
{ $uname = fgets($fp,filesize("compra.txt"));
$line = $line + 1;
$uname2=chop($uname);
$res = preg_split("/####/",$uname2);
if ($res[0] || $res[1] || $res[2] || $res[3] || $res[4] || $res[5] || $res[6] || $res[7] || $res[8] || $res[9] || $res[10] ) {
if ($line == "$entry") {
echo "<table $tablestuff>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>id<td $tdstuff><font face =$font size=$fsize color=$fcolor>$line<TR>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field1name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[0]<TR>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field2name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[1]<TR>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field3name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[2]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field4name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[3]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field5name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[4]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field6name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[5]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field7name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[6]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field8name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[7]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field9name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[8]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field10name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[9]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>Date<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[10]";
echo "</table><BR><br>";
}
}
if ($res[0] || $res[1] || $res[2] || $res[3] || $res[4] || $res[5] || $res[6] || $res[7] || $res[8] || $res[9] || $res[10] ) {
if ($entry == "all") {
echo "<table $tablestuff>";
//echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>id<td $tdstuff><font face =$font size=$fsize color=$fcolor>$line<TR>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field1name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[0]<TR>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field2name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[1]<TR>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field3name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[2]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field4name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[3]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field5name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[4]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field6name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[5]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field7name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[6]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field8name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[7]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field9name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[8]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>$Field10name<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[9]<tr>";
echo "<td $tdstuff><font face =$font size=$fsize color=$fcolor>Date<td $tdstuff><font face =$font size=$fsize color=$fcolor>$res[10]";
echo "</table><BR><br>";
}
}
}
fclose($fp);
}
?>