Security issues while using external javascript and php files to access mysql database in drupal nodes
Doesn't look like any of the questions you have are directly related to Drupal. I highly suggest reading about PHP security concerns. This is a good resource to get started.

That said:


  Is this method secure?


Without looking at specific code, that is hard to say. Since you're running a database query based on user input, it's important you properly sanitize the input before running the query. I suggest using PDO instead of mysqli_* functions, since PDO is more widely used now and provides easy ways to use "prepared statements" to protect your database.


  Can some anonymous user access my .php script and get to know my mysql
  admin password? ( I use admin password during mysqli_connect() )


Not unless the .php script prints the password to the screen. Sounds like it accepts POST data and will return JSON output with data from the database. Make sure your POST data in sanitized before running a query.


  Can my whole database be exposed easily even though I always query a
  single table of the database?


See above


  Can the .php file be edited to update or delete parts of my database
  or the table in which I query every time?


Not unless a malicious user has access to your web server