Results 1 to 2 of 2

Thread: Append incremental

  1. #1
    Join Date
    Jul 2006
    Posts
    142
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Append incremental

    Very simple question i have this code

    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.

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

    Code:
    1 Mary 
    2 Jane
    3 Mark
    Thanks

  2. #2
    Join Date
    Jul 2006
    Posts
    142
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    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?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •