Storing newly Incremented number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jalley06
    New Member
    • Mar 2008
    • 20

    Storing newly Incremented number

    Hi all,

    I have a form with a field called ReportID in aspx on our local Intranet. Everytime this report is loaded into a browser, I need the ReportID field to be incremented by one. I got this to work with Javascript except when the page was closed and reloaded, the ReportID field was set back to one instead of storing the new number and incrementing from there.

    I was told that writing a PHP script and storing the incremented number in a file or db would be my best option.

    Can someone please let me know where I need to start in order to do this?

    Thanks.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Are you able to use a database? Such as MySQL?

    If so, there are many, many tutorials out there - and from what i read you're needs are pretty basic.

    Comment

    • jalley06
      New Member
      • Mar 2008
      • 20

      #3
      Originally posted by markusn00b
      Are you able to use a database? Such as MySQL?

      If so, there are many, many tutorials out there - and from what i read you're needs are pretty basic.
      I would be able to use SQL Server but would prefer just using a flat file if possible. I don't want to clutter up our SQL server db with just one column for storing numbers. Is that possible?

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by jalley06
        I would be able to use SQL Server but would prefer just using a flat file if possible. I don't want to clutter up our SQL server db with just one column for storing numbers. Is that possible?
        Sure it's possible!

        Have a look at tizag.com's file tutorials


        When you've had a play around, come back and we'll help you from there :)

        Comment

        • jalley06
          New Member
          • Mar 2008
          • 20

          #5
          Originally posted by markusn00b
          Sure it's possible!

          Have a look at tizag.com's file tutorials


          When you've had a play around, come back and we'll help you from there :)
          Thanks for the tutorial and now for my questions. :-)

          Here is what I have for code:

          [PHP]
          $ourFileName = "reportid.t xt";
          $fh = fopen($ourFileN ame, 'r') or die("Can't open file");
          $theData = fgets($fh);
          fclose($fh);
          echo $theData;
          [/PHP]

          I have created a file called ReportID.txt and typed a list of numbers in it: i.e. 1000
          1001
          1002...etc.

          First question: Where do I put this code on my page so that the value that is read into the script (for ex: 1000) displays in my ReportID text box? I understand that echo means display what's in the text file but I want it to put that value in my text box on my page.

          Second question: Does the script know to read the next line of the ReportID.txt file when the page is loaded again or do I need to use Append+ (a+) instead of Read (r)? **update (I answered this question myself, so ignore it** :-)

          Thanks!

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            If you mean by text box, an input text field (and not an input drop down box) something like[php]echo "<input type='text' name='txtname' value='$theData ' />";[/php]will do.

            Ronald

            Comment

            Working...