Display Data by calling function to another php page in wordpress

admin

Administrator
Staff member
im still new to wordpress and not that good in coding much in php but i do know the basics. I have here my main code file for my plugin called hello-world.php and another php file called display-data.php. i kinda confused on how you display data by using a function to call it on another page which in mine called display-data.php here is my code for hello-world.php

Code:
function wpdisplay(){
    global $wpdb;
    global $result;
    $result = $wpdb->get_results("
    SELECT * FROM wp_options WHERE option_id = '262'
    ", ARRAY_A);
    print_r($result);
}
register_activation_hook('activate_hello-world/display-data.php' ,'wpdisplay');

i have a button form in my main file that directs to display-data.php where it should display the data. i tried calling it by wpdisplay();

however it gives me an error like this.
<strong>Call to undefined function wpdisplay() in /Applications/MAMP/htdocs/wordpress/wp-content/plugins/hello-world/display-data.php</strong>

hope you could help me and explain if there is something that i am missing. thanks