Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/11/2011, 11:22
lems1o
 
Fecha de Ingreso: julio-2011
Mensajes: 161
Antigüedad: 12 años, 8 meses
Puntos: 3
como hacer correlativo de numeros en array

Buenas tardes amigos, tenia la siguiente duda nose si me podrian ayudar:

Tengo el sgt codigo lo que mas me interesa es la $i porque lo que deseo es que me imprima un correlativo 1,2,3,4,5 pero lo imprime asi:(Repite 3 veces el numero)
Gracias de antemano, cualquier ayuda idea lo que sea porfavor gracias.


CABINETS & RACKS SAC 621.18 1 03/01/2011
CABINETS & RACKS SAC 522.00 1 03/01/2011
CABINETS & RACKS SAC 99.18 1 03/01/2011
PACIFICO SA 7827.61 2 03/01/2011
PACIFICO SA 6577.82 2 03/01/2011
PACIFICO SA 1249.79 2 03/01/2011
PACIFICO SA 566.98 3 03/01/2011
PACIFICO SA 476.45 3 03/01/2011
PACIFICO SA 90.53 3 03/01/2011
PACIFICO SA 1380.01 4 03/01/2011
PACIFICO SA 1159.67 4 03/01/2011
PACIFICO SA 220.34 4 03/01/2011
PACIFICO SA 194.21 5 03/01/2011
PACIFICO SA 163.20 5 03/01/2011
PACIFICO SA 31.01 5 03/01/2011


<?php
include("Conexion.php"); //conexion
$sql = mysql_query("SELECT * FROM mgtrading") or die ("Error en el query: ".mysql_error());
//$cad ="";
$i=0;
while($rs=mysql_fetch_array($sql)){


$PROVEEDOR= $rs['PROVEEDOR'];
$total = $rs['TOTAL'];
$fecha = $rs['FECHA'];
$BASEIMP_CON_DERCF = $rs['BASEIMP_CON_DERCF'];
$IGV_CON_DERCF = $rs['IGV_CON_DERCF'];
$i++;


$tabla[] = $PROVEEDOR . "\t";
$tabla[] = $total . "\t"; //DIMPORT
$tabla[] = $i . "\t"; //DIMPORT
$tabla[] = $fecha . "\t"; //DDATE
$tabla[] = "\r\n";

$tabla[] = $PROVEEDOR . "\t";
$tabla[] = $BASEIMP_CON_DERCF . "\t"; //DIMPORT
$tabla[] = $i . "\t"; //DIMPORT
$tabla[] = $fecha . "\t"; //DDATE
$tabla[] = "\r\n";

$tabla[] = $PROVEEDOR . "\t";
$tabla[] = $IGV_CON_DERCF . "\t"; //DIMPORT
$tabla[] = $i . "\t"; //DIMPORT
$tabla[] = $fecha . "\t"; //DDATE
$tabla[] = "\r\n";

}
$tabla = join('', $tabla);
file_put_contents('prueba.txt', $tabla);
?>