Ver Mensaje Individual
  #11 (permalink)  
Antiguo 18/02/2010, 07:51
Avatar de hector2c
hector2c
 
Fecha de Ingreso: noviembre-2007
Ubicación: Perú - Tacna
Mensajes: 979
Antigüedad: 16 años, 5 meses
Puntos: 25
Pregunta Respuesta: filtrar contenido de archivo txt

este es el index.php

Código HTML:
<table border="1">
	<thead>
    	<tr>
        	<th>ide</th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
        </tr>
    </thead>
    <tbody>
<?
	$lines = file('fichero.txt');
	foreach ($lines as $line_num => $line) {
		$datos = explode("#", $line);
?>
        <tr>
            <td><?=$datos[0];?></td>
            <td><?=$datos[1];?></td>
            <td><?=$datos[2];?></td>
            <td><?=$datos[3];?></td>
            <td><?=$datos[4];?></td>
            <td><?=$datos[5];?></td>
            <td><?=$datos[6];?></td>
            <td><?=$datos[7];?></td>
            <td><a href='modificar.php?ide=<?=$datos[0]?>'>modificar</a></td>
        </tr>
<?
	}
?>
    </tbody>
</table> 

este es el modificar.php

Código HTML:
<?
	$ide = $_GET['ide'];
	if(isset($_POST['campo_1'])){
		/*
			obtenemos el ide y modificamos
		*/
		$ide = $_POST['ide'];
		/*
			código para modificar
		*/
	}

	$lines = file('fichero.txt');
	foreach ($lines as $line_num => $line) {
		$datos = explode("#", $line);
		if($datos[0]==$ide){
?>
    <form method="post" action="modificar.php">
        <input type="hidden" name="ide" value="<?=$datos[0]?>" />
        <table border="1">
            <tbody>
                <tr>
                    <td>Ide</td>
                    <td><?=$datos[0];?></td>
                </tr>
                <tr>
                    <td>Campo 1</td>
                    <td><input type="text" name="campo_1" value="<?=$datos[1]?>" /></td>
                </tr>
                <tr>
                    <td>Campo 2</td>
                    <td><input type="text" name="campo_1" value="<?=$datos[2]?>" /></td>
                </tr>
                <tr>
                    <td>Campo 3</td>
                    <td><input type="text" name="campo_1" value="<?=$datos[3]?>" /></td>
                </tr>
                <tr>
                    <td>Campo 4</td>
                    <td><input type="text" name="campo_1" value="<?=$datos[4]?>" /></td>
                </tr>
                <tr>
                    <td>Campo 5</td>
                    <td><input type="text" name="campo_1" value="<?=$datos[5]?>" /></td>
                </tr>
                <tr>
                    <td>Campo 6</td>
                    <td><input type="text" name="campo_1" value="<?=$datos[6]?>" /></td>
                </tr>
                <tr>
                    <td>Campo 7</td>
                    <td><input type="text" name="campo_1" value="<?=$datos[7]?>" /></td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="2">
                        <input type="submit" value="Modificar" />
                        <input type="button" value="Cancelar" onclick="window.location = 'index.php';" />
                    </td>
                </tr>
            </tfoot>
        </table>
    </form>
<?
			break;
		}
	}
?> 
el código para modificar lo puedes buscar en internet, ando corto en tiempo jejeje
__________________
blog: hector2c.wordpress.com
email: [email protected]