I am using HostMonster as my hosting company and I am trying connect with a database I produced using MySQL within HostMonster. To be able to call that database during my website should i use PHP? Or it is possible to way to produce a javascript OnClick function that may call the database. I am not using ASP.Internet therefore it is less than as easy as I'd like it. Just curious when the best answer is PHP, if that's the case I suppose I ought to go learn it.

Your javascript onClick function is running around the client side (within the browser) and also the database is running around the server-side. You may need a server-side language to obtain the information in the database and send it towards the browser.

what exactly are you planning related to the database, apart from just 'calling it'? You'll need some language like PHP for connecting towards the DB to retrieve, place, update or remove data within the DB.

this is a code for connection MySQL from PHP using MYSQLI extension


$con=mysqli_connect($dba_host,$dba_name,$dba_pass,$dba_db) or die('Connection Refused !');

$stmt=mysqli_prepare($con,"SELECT UID FROM Main");
mysqli_stmt_bind_result($stmt, $value);
 $result[] = $value;

You don't have to make use of PHP for connecting to some MYSQL database. Also, you cannot connect with your database only using javascript. You should utilize a server side language, PHP is a choice.

For connecting to some MYSQL database on hostmonster using PHP you will have to know your qualifications which use to log into phpMyAdmin out of your cpanel. After you have made the bond after that you can choose the MYSQL database that you simply produced. When the database is chosen you are able to query it while using "mysql_query" function in PHP. The next code does all that and stores the outcomes from the MYSQL query inside a PHP variable known as $result.

$con = mysql_connect("www.yourdomain.com","phpMyAdmin_username","phpMyAdmin_password");
if (!$con)
  die('Could not connect: ' . mysql_error());

mysql_select_db("mysql_database_name", $con);

$query = "SELECT * FROM TableName"
$result = mysql_query($query);


Now you have the outcomes from the query within the PHP variable $result and technology-not only anyway you want.

Should you put this inside your 'public_html' folder and referred to it as 'index.php' or 'index.html' this could instantly be run when someone visited www.yourdomain.com.

You'll find an excellent tutorial series on PHP here http://thenewboston.org/list.php?cat=11.