Log in

View Full Version : Append incremental



neo_philiac
06-11-2008, 05:45 PM
Very simple question i have this code


<?php
$Handle = fopen("file.txt", "a+") or
die( "Error opening file" );

if (!fwrite($Handle, $_POST['addition'] . "\n"))
{
die( "Error writing to file!" );
}
fclose($Handle) or
die( "Error closing file!" );


?>
<form action="<?=$PHP_SELF?>" method="post">
<input type="text" name="addition"/><br/>
<input type="submit"/>
</form>



To append string into a text file with a newline. So, now if you see the text file, it looks like.


Mary
Jane
Mark

How do I get it to increment the last (number +1) every time I append the data :


1 Mary
2 Jane
3 Mark

Thanks

neo_philiac
06-13-2008, 06:45 PM
So I got the the incremental problem fixed now that I have the data, can I create an excel file and pust the data with php? I it possible? If sp, how?