Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How to store numeric form values and retieve the total sum of them.

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #281917
    snippet248
    Participant

    I’m attempting to recreate this: http://rinchencholing.org/#whitetara
    Which allows to submit numeric values and automatically update and display the total number of sumbmited values. I know how to create the form, but I don’t know how to store entered values and update the total accordingly.

    #282180
    Beverleyh
    Participant

    You can use PHP’s file_put_contents() to save the entered form values into a text file. Then you can retrieve the content of the text file and display them on the page with file_get_contents() and echo()

    Here’s a simple demo that uses the same logic except it’s updating a stylesheet http://fofwebdesign.co.uk/template/_testing/test/save-file/index.php

    #282254
    snippet248
    Participant

    Thank you!!! and what is that the best way to store values so that is easier to view/check and edit the submissions? maybe storing it in a table or excel? or like a post in wordpress? the website is running on wordpress…

    #282270
    Beverleyh
    Participant

    A database table is also another option, then you could edit entries via something like phpMyAdmin in your web host control panel, or you could make your own admin panel. It just depends how much effort you want to put in.

    There are PHP database management scripts out there such as https://www.adminer.org and http://phpminiadmin.sourceforge.net for you to edit an existing database but you’d have to devise the structure and write the code for the web page to communicate with the backend.

    Alternatively, you could try a ready-made form and database management application such as Form Tools, which handles form-to-db communication and stores submissions separately, where you can edit via a backend admin panel and export into Excel https://formtools.org

    You would need to research more to test capabilities and see what suits your needs.

    #282951
    snippet248
    Participant

    Thanks again!! I’m not sure whats best. What if I use a CSV or a regular html table? which are easy to edit/check and not as complex as mysql perhaps.
    If those are good choices.. how to write to the right column/row for the table or the CSV file?

    #282961
    Beverleyh
    Participant

    Editing rows: To find out more about targeting individual rows/lines in a single text/csv file, Google something like “php edit specific line in text file” to begin your research – it usually involves reading the lines of a text file into memory and numbering them along the way. OR, you can store each row/line in its own text file, and the file name could be the row identifier (rather than the line number from a single larger file stored in memory).

    Editing columns: if you use a delimiter (e.g. ”##”) to separate cell data in each column, you can use explode() in PHP to separate the data at that delimiter when you retrieve it, then you can use implode() and the same delimiter to join the column data back together when you save it again.

    When assessing what’s good for your project, only you can make that assessment I’m afraid. You might have to try out/research several solutions until you come up with something that fits your needs/scale/time/budget/skill, etc.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.