This topic is locked

capture a variable

4/30/2011 5:49:45 AM
PHPRunner General questions
B
bobby321 author

Hi Forum
Having a problem, I am trying to apture a variable $Num I am generating in After record processed event.
How do I us the value in another variable I have tried $value[X] = $Num, $value[X] = ($Num) etc but nothing seems to return a result all I get is symtax errors.
Any help with is appreciated, its driving me nuts.
thanks

Sergey Kornilov admin 4/30/2011

According to the manual you can access the value of any field in the current record as $data["FieldName"].
More info:

http://xlinesoft.com/phprunner/docs/after_record_processed.htm

B
bobby321 author 4/30/2011



According to the manual you can access the value of any field in the current record as $data["FieldName"].
More info:

http://xlinesoft.com/phprunner/docs/after_record_processed.htm


thanks Admin
But this variable is generated as follows:
$date1 = strtotime($data["Date1"]);

$CurrentDate = strtotime(date("d-m-Y")); $sub = $CurrentDate - $date1; $Days = floor(($sub)/86400);
As you can see $Days is not a field in the current record, what i want to do is place the value of $Days in a table field.
Thanks

Sergey Kornilov admin 4/30/2011

When you saying "place the value of $Days in a table field" - do you mean ave this value in the database or simply display it somewhere on the page?

B
bobby321 author 4/30/2011



When you saying "place the value of $Days in a table field" - do you mean ave this value in the database or simply display it somewhere on the page?


Hi Sergey
Yes, I want to use it in another calculation, so placing it in the database or anywhere that I can few it and use it.
Thanks

Sergey Kornilov admin 4/30/2011

I guess you need to provide a full picture. Its not clear if you want to save it permanently or temporary.

B
bobby321 author 5/1/2011



I guess you need to provide a full picture. Its not clear if you want to save it permanently or temporary.


Hi Sergey
I would link to save it temporary, as i would like the recalculate the $Days every time the table is loaded
Thanks

Sergey Kornilov admin 5/2/2011

The question you need to ask yourself - do you really want to update your database multiple times on each page load?
The number of days only changes once a day, why would you want to update it that often. If you only need to calculate and display the number of days between two days you can do this right in SQL query.
DATEDIFF() function gives you the number of days between two dates:

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_datediff

B
bobby321 author 5/2/2011



The question you need to ask yourself - do you really want to update your database multiple times on each page load?
The number of days only changes once a day, why would you want to update it that often. If you only need to calculate and display the number of days between two days you can do this right in SQL query.
DATEDIFF() function gives you the number of days between two dates:

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_datediff


Thanks Sergey
To explain, one date the rental date is fixed, and every day after the date is another days rental so the rental rate has to add anothers days rental charge at the start of each day, hence the Current Date - date1 = $Days the weekly rental / 7 * Days returns the current rental charge.
I hope this explains the daily update questuion.
I did look at the DATEDIFF() function but had some trouble using it in 5.3 for some reason the SQL entry section didnt like it, i will look at it again.
Thanks

Sergey Kornilov admin 5/2/2011

The issue is that instead of daily update you will be updating database probably a thousand times. Calculated value is the way to go and it's much easier to setup.
You can contact support directly if you need help using DATEDIFF function. We'll need to see your sample database in order to provide help.

B
bobby321 author 5/2/2011



The issue is that instead of daily update you will be updating database probably a thousand times. Calculated value is the way to go and it's much easier to setup.
You can contact support directly if you need help using DATEDIFF function. We'll need to see your sample database in order to provide help.


Thanks Sergey
I will come back to you once I have look at it again
Thanks for the great support
Thnaks