Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: beginner question (Read 2786 times) previous topic - next topic

beginner question

Im trying to make a field called account a global variable so I can use it later.

I put this in the after view form of that record, but no luck.. can any please point me in the right direction.
I want to store the account number of the file called customer to a global variable to use later...

  
<?php
   $val = $modeldata['account'];
   function display() {
      GLOBAL $val;
   }
?>


Re: beginner question

Reply #1
@nightcasters‍ you can use session (set_session("name", "value"), get_session("name"), and clear_session("name")) or cookies (set_cookie("name", "value"), get_cookie("name"), and clear_cookie("name")) to store values and retrieve them on any page, please referer to the View Helper at the top right corner of the phprad application.

Re: beginner question

Reply #2
Thanks willvin.
But how can I refer to values that I just retrieved from the db and are now visible on the screen?
Isn’t there a general approach to address these values?
For example if a view page of a record from a table called: customers with fields called: id, name, city.
Is there something like $table.field or $table[1] that we can use?

Re: beginner question

Reply #3
@Erwin‍ there are different ways of access data depending on where you are getting the data and where you want to use it. Please provide more info on what you mean, thanks.

Re: beginner question

Reply #4
Thank you @willvin, I tried following this post https://phprad.com/forum/index.php?topic=401.0
You showed passing on $data['example'] in that post about a year ago, but I cannot find the recordID field on Page Design.

What I want is this:
Client has many orders. On page I show client info plus a subpage with list view of the orders.
I want to add a new order for that particular client (so not having to lookup the client but preselecting it).
Then order is added, modal is closed and client view is refreshed and the list of orders shows the old orders plus the order just placed.