This topic is locked
[SOLVED]

 Button to View record in another Table

1/12/2021 7:27:07 AM
PHPRunner General questions
W
wypman author

I have created several tables, all of which update a master table using triggers. Within the master table is the database name and record id that the master table record is linked too. I would like to create a button on the list (page or view) that once clicked would view the record from the linked table.
I am just wondering the best way of doing this.

admin 1/12/2021

A first step would be to craft such a link to another table view page manually. Then you can re-create such a link in your code and see example #6 at https://xlinesoft.com/phprunner/docs/inserting_button.htm to open a link via button.

W
wypman author 1/13/2021

Thank you for your kind assistance. I have successfully created the button code using the following code in the Server event code.

$db = $button->getCurrentRecord();
// Get Database Name and record id

$database_name = $db['database_name'];

$database_id = $db['database_id'];
// build URL

$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://';;

$hostName = $_SERVER['HTTP_HOST'];

$currentPath = $_SERVER['PHP_SELF'];

$pathInfo = pathinfo($currentPath);

$url = $protocol.$hostName.$pathInfo['dirname']."/";
// add record link information to suffix of URL

$record_url = $url.$database_name."_view.php?editid1=".$database_id;
$result['url'] = $record_url;


In the button Client After I simply pass the 'url' to a window.open command.

window.open(result["url"], "_blank");


This works great, but I have noticed that when it opens the page in a new tab, the [back to list] button returns to the table from which the record was extracted and not the master table. Is there a way of returning to the master table or disabling the [back to list button]

H
Hd_Mersintarim 1/13/2021



Thank you for your kind assistance. I have successfully created the button code using the following code in the Server event code.

$db = $button->getCurrentRecord();
// Get Database Name and record id

$database_name = $db['database_name'];

$database_id = $db['database_id'];
// build URL

$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://';;

$hostName = $_SERVER['HTTP_HOST'];

$currentPath = $_SERVER['PHP_SELF'];

$pathInfo = pathinfo($currentPath);

$url = $protocol.$hostName.$pathInfo['dirname']."/";
// add record link information to suffix of URL

$record_url = $url.$database_name."_view.php?editid1=".$database_id;
$result['url'] = $record_url;


In the button Client After I simply pass the 'url' to a window.open command.

window.open(result["url"], "_blank");


This works great, but I have noticed that when it opens the page in a new tab, the [back to list] button returns to the table from which the record was extracted and not the master table. Is there a way of returning to the master table or disabling the [back to list button]


delete back to list button and add new button and customize this button link

W
wypman author 1/13/2021

Thank you for the response, I have just deleted the Back to List button all together.