I am working on a site called MyFish.com that is a fishing and biological data log. I have two dropdown fields on this form http://www.myfish.com/enter-a-fishing-trip-log/ (user:demofisherman / pass:demo) that I want to total and display in a text widget as a counter in the sidebar.
The fields are fish caught and fish released which are both numerical dropdowns.. Each form submission has a variable amount of fish caught and released.
Example:
fisherman 1: 15 fish caught | 10 released
fisherman 2: 25 fish caught | 12 released
I want to extract the meta for ALL entries for these specific fields on this one form and display a running total as users enter fish in the log. Is this possible using the current hooks, filters and a little php? I have a functioning "counter" working on the thank you page and in the sidebar by passing two variables in the url (fishcount and fishreleased) to the thank you page and running the following code in the post. The code updates a simple text document and uses similar code to echo it in the sidebar in a text widget.
Thank you for logging your <?php $fishcount=$_GET["fishcount"]; echo $fishcount; ?> fish!
Total fish logged on MYFish.com:
<?php
$fishcount=$_GET["fishcount"];
if (file_exists('count_file.txt'))
{
$fil = fopen('count_file.txt', r);
$dat = fread($fil, filesize('count_file.txt'));
echo $dat+$fishcount;
fclose($fil);
$fil = fopen('count_file.txt', w);
fwrite($fil, $dat+$fishcount);
}
else
{
$fil = fopen('count_file.txt', w);
fwrite($fil, 1);
echo '1';
fclose($fil);
}
?>
Total fish Released:
<?php
$fishreleased=$_GET["fishreleased"];
if (file_exists('count_released.txt'))
{
$fil = fopen('count_released.txt', r);
$dat = fread($fil, filesize('count_file.txt'));
echo $dat+$fishcount;
fclose($fil);
$fil = fopen('count_released.txt', w);
fwrite($fil, $dat+$fishreleased);
}
else
{
$fil = fopen('count_released.txt', w);
fwrite($fil, 1);
echo '1';
fclose($fil);
}
?>
I know this method presents a lot of problems and querying the actual entries is the correct way. How do I do this?