Parsing CSV File to display on a WFB...

User 187934 Photo


Senior Advisor
20,195 posts
Online Now

All the code changes are done after manual export in the forms actual html code.
So on your test form it would be here.
https://files.farmtronics.com.au/004WZ_ … 004WZ.html
But you need to change the forms extension from .html to .php
004WZ.html to 004WZ.php
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2836110 Photo


Registered User
109 posts

Morning Eric,
I have done the following:
Pasted the script into the 004WZ.html file and saved it from html to php.
All i get is a blank page ??

I am still not certain where i place the input name scripts for each trailer ?
You are probably getting frustrated with me and i apologize, especially after all the effort you made to help me.
But i am obviously missing something.
Probably brain cells LOL
User 2836110 Photo


Registered User
109 posts

Blank page occurs after i submit.
User 187934 Photo


Senior Advisor
20,195 posts
Online Now

The blank page is probably a php parsing error. You can look in the directory that holds the form and see if there is a page named something like error_log. You can change it to error_log.txt to make it viewable within a html editor or word processor. It will point to the line in your page that has the error.
As far as the inputs go I posted how yours would look assuming your using the same form for testing.
<input name="TrailerA" disabled id="item80_text_1" type="text" maxlength="254"
data-hint="" autocomplete="off" value="<?php echo (!empty(array_sum($sumTrailerA)) ? array_sum($sumTrailerA) : '');?>" />

All you actually need to do is add this to each trailer input.
value="<?php echo (!empty(array_sum($sumTrailerA)) ? array_sum($sumTrailerA) : '');?>"

This one is for Trailer A so add it to the other inputs and adjust the variable names to meet that Trailer name and the Cumulative input.
All were doing is adding the value="" attribute to the inputs and having php fill it in.
Take your time. We'll get you up and running.

I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2836110 Photo


Registered User
109 posts

Appreciate you help Eric, but if you get frustrated just let me know and i will understand.
I will still keep you on my Xmas card list lol

Just confirming the Trailer inputs i place on the form using the HTML element ?
User 2836110 Photo


Registered User
109 posts

Hi Eric, This is what i have added to the /004WZ/004WZ.php file
There is also a 004WZ.php file in the root directory and after pressing submit it seems to want to go back to that file ?? Ending up with a Bad Gateway error.
It seems to be getting very complicated.

<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$f = fopen("storage/csv/WZ.csv", "r");
date_default_timezone_set('Australia/Melbourne');
$sumTrailerA = array();
$sumTrailerB = array();
$sumTrailerC = array();
$sumTrailerD = array();
$sumTrailerTotal = array();
while (($line = fgetcsv($f)) !== false) {
$submitted_date = $line[0];
$current_date_formatted = date("d/m/Y");
if( $submitted_date == $current_date_formatted){
$Trailer=preg_replace('/\s+/', '', $line[7]);
if($Trailer == "TrailerA"){
array_push($sumTrailerA,$line[11]);
}else if($Trailer == "TrailerB"){
array_push($sumTrailerB,$line[11]);
}else if($Trailer == "TrailerC"){
array_push($sumTrailerC,$line[11]);
}else if($Trailer == "TrailerD"){
array_push($sumTrailerD,$line[11]);
}
array_push($sumTrailerTotal,$line[11]);
}
}
fclose($f);
?>
value="<?php echo (!empty(array_sum($sumTrailerA)) ? array_sum($sumTrailerA) : '');?>"
value="<?php echo (!empty(array_sum($sumTrailerB)) ? array_sum($sumTrailerB) : '');?>"
value="<?php echo (!empty(array_sum($sumTrailerC)) ? array_sum($sumTrailerC) : '');?>"
value="<?php echo (!empty(array_sum($sumTrailerD)) ? array_sum($sumTrailerD) : '');?>"
value="<?php echo (!empty(array_sum($sumTrailerTotals)) ? array_sum($sumTrailerTotals) : '');?>"


<!DOCTYPE HTML>
User 2836110 Photo


Registered User
109 posts

Getting Closer, i can see the values at the top of the page.
https://files.farmtronics.com.au/004WZ_ … /004WZ.php
User 187934 Photo


Senior Advisor
20,195 posts
Online Now

Woot Woot!!
We know your close.:cool:
Where did you put the input code at? The input TrailerA has no value="" so I don't think you put them in.
<input name="TrailerA" disabled id="item80_text_1" type="text" maxlength="254"
placeholder="" data-hint="" autocomplete="off" />

If you just pasted them into your page at the top you just need to move each one to it's proper location in each input.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2836110 Photo


Registered User
109 posts

I actually used this only:

value="<?php echo (!empty(array_sum($sumTrailerA)) ? array_sum($sumTrailerA) : '');?>"
User 187934 Photo


Senior Advisor
20,195 posts
Online Now

Lou Mitsy wrote:
I actually used this only:

value="<?php echo (!empty(array_sum($sumTrailerA)) ? array_sum($sumTrailerA) : '');?>"

Did you paste that into your input html? Because if you did the value="" would be there whether the php had a value or not.
Find each input in your html and paste that near the end just before /> of the input.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.