Adding jquery using php function

Why are you not using the built-in enqueue_script function? Simply put your custom jQuery code into a file called custom.js, save it into your plugin or theme folder, then enqueue it with jQuery as a dependency:

<?php
function custom_scripts() {
    if (is_admin()){
        wp_enqueue_script(
            'customjs',
            get_template_directory_uri() . '/js/custom.js',
            array('jquery')
        );
    }
}
add_action('wp_enqueue_scripts', 'custom_scripts');

You’ll need to change the get_template_directory_uri() function to get the proper path of your plugin, but that’s basically it.

EDIT: You WANTED it in the admin. Missed that.