<?php
$databasehost = "www.xxxx.com";
$databasename = "xxxxDB";
$databaseusername = "xxxx2";
$databasepassword = "xxxx";
$con=mysqli_init();
if (!$con)
{
die("mysqli_init failed");
}
mysqli_ssl_set($con,"key.pem","cert.pem","cacert.pem",NULL,NULL);
if (!mysqli_real_connect($con,$databasehost,$databaseusername,$databasepassword,$databasename))
{
die("Connect Error: " . mysqli_connect_error());
}
// Some queries...
$q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID=40001762");
$rows = array();
while($r = mysqli_fetch_assoc($q))
{
$rows[] = $r;
}
print json_encode($rows);
mysqli_close($con);
mysqli_close($con);
$action = $_GET["action"];
switch ($action)
{
case "CountPersons":
$q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID=40001762");
$count = mysqli_num_rows($q);
print json_encode($count);
mysqli_close($con);
break;
Case "GetPersons":
$q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID=40001762");
$rows = array();
while($r = mysqli_fetch_assoc($q))
{
$rows[] = $r;
}
print json_encode($rows);
mysqli_close($con);
break;
case "InsertNewPerson":
$name = $_GET["name"];
$age = $_GET["age"];
$q = mysqli_query($con,"INSERT INTO UserRegister (CustomerName, CustomerNo) VALUES ('$name', $age)");
print json_encode("Inserted");
mysqli_close($con);
break;
}
?>