D
|
david22585 8/28/2019 |
Try something like this:
$sql = "SELECT(end) AS start FROM TABLE_NAME ORDER BY id DESC LIMIT 1"; |
![]() |
Tandy author 8/29/2019 |
Try something like this:
$sql = "SELECT(end) AS start FROM TABLE_NAME ORDER BY id DESC LIMIT 1";
$sql = "SELECT(end_odometer) AS start_odometer FROM trip_report ORDER BY trip_report_id DESC LIMIT 1"; |
![]() |
Tandy author 8/29/2019 |
Question. Is there a way to put a code in the fields as custom to auto populate the start_odometer with the last trip_report_id end_odometer? So that way if the odometer has changed for some reason they can replace the start_odometer with the correct start_odometer? |
S
|
smez 8/30/2019 |
Your last line is incorrect. It should be: $values['start_odometer'] = $data["start_odometer"]; Thank You for your help david22585. I tried adding the code to Events - Add Page Before Process. It did not fill in the end_odometer from the start_odometer. Here is the code I tried: $sql = "SELECT(end_odometer) AS start_odometer FROM trip_report ORDER BY trip_report_id DESC LIMIT 1"; |
![]() |
Tandy author 8/30/2019 |
Thank You smez, $sql = "SELECT(end_odometer) AS start_odometer FROM trip_report ORDER BY trip_report_id DESC LIMIT 1"; to the add page :: Before process and I tried Add page :: Before Display. Nether one put the odometer in? Your last line is incorrect. It should be: $values['start_odometer'] = $data["start_odometer"]; |
S
|
smez 8/30/2019 |
You copied my suggestion incorrectly. Since you extracted the value using sql "AS start_odometer" - you must reference it using the $data variable as in my example. Thank You smez, Just tried and still it is not putting anything in the start_odometer from the end_odometer. I am wondering maybe if the code is right if I am not putting it in the right place. I am adding: $sql = "SELECT(end_odometer) AS start_odometer FROM trip_report ORDER BY trip_report_id DESC LIMIT 1"; to the add page :: Before process and I tried Add page :: Before Display. Nether one put the odometer in? |
D
|
david22585 8/30/2019 |
That code would insert the field into the database, not fill it in automatically into the box. I haven't tried the code, but try something like this: global $strTableName, $conn;
$_SESSION["start_odometer"] |
![]() |
Tandy author 8/30/2019 |
Thank you david22585,That worked out great.. Does what I need it to do.. That code would insert the field into the database, not fill it in automatically into the box. I haven't tried the code, but try something like this: Events -> Before Proces global $strTableName, $conn;
$_SESSION["start_odometer"] |
![]() |
Tandy author 8/30/2019 |
Is there a way to lock it down to just that account? Something like this work?
|
D
|
david22585 8/31/2019 |
Is there a way to lock it down to just that account? Something like this work?
|
![]() |
Tandy author 8/31/2019 |
The session is only good for when they load the add page. Every time the add page is loaded, it will retrieve the data end_odometer and set it as a new session variable just for the add page. Thank you very much david22585Hmmm.. This will work for now but will have to see if I can lock it done to the truck_id that stays good for that truck.. Do you know where I could find something like that? |
D
|
david22585 9/2/2019 |
Thank you very much david22585Hmmm.. This will work for now but will have to see if I can lock it done to the truck_id that stays good for that truck.. Do you know where I could find something like that? ThanksJames
|
![]() |
Tandy author 9/2/2019 |
I'm assuming that you want to read the last odometer for a certain truck and use that value, correct?
|
D
|
david22585 9/2/2019 |
Yes, exactly. I have truck underscore number to lock the odometer readings. Thank you for all of your help. James Tandy
|
![]() |
Tandy author 9/2/2019 |
The biggest thing is how are you accessing the truck value, by a link on the view or list page of a truck, or by a drop down selection on the add page?
|
D
|
david22585 9/2/2019 |
Try this: global $strTableName, $conn;
|
![]() |
Tandy author 9/3/2019 |
Try this: global $strTableName, $conn;
// Take end_odometer and auto put into start_odometer - Start Maybe it can help someone else. Also a big thanks to the Admin on letting me know where it goes. |
D
|
david22585 9/3/2019 |
Thank You very much for all your help david22585. You helped out so much.. Still learning all this.. Here is the code that works out great. Put in ADD and EDIT pages on the Process Record Values: // Take end_odometer and auto put into start_odometer - Start Maybe it can help someone else. Also a big thanks to the Admin on letting me know where it goes.
|