I am using an Arduino Yun for my project. I need to download data from web host, 000webhost, mysql database to my Arduino Yun. How can I achieve that? I want to use php file, which should be working independently. How should I on the Arduino Yun side. Here is my PHP script code:
<?php
$db_name = "00000";
$mysql_user = "0000";
$mysql_pass = "0000";
$server_name = "mysql9.000webhost.com";
$con = mysqli_connect($server_name,$mysql_user,$mysql_pass,$db_name);
$dname = $_GET["dname"];
$dlastname = $_GET["dlastname"];
$pname = $_GET["pname"];
$plastname = $_GET["plastname"];
$statement = mysqli_prepare($con, "SELECT * FROM drug WHERE dname = ? AND dlastname = ? AND pname = ? AND plastname = ?");
mysqli_stmt_bind_param($statement, "ssss", $dname, $dlastname, $pname, $plastname);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $userID, $dname, $dlastname, $pname, $plastname, $drug, $time, $minute, $amount, $op);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["userID"] = $userID;
$response["dname"] = $dname;
$response["dlastname"] = $dlastname;
$response["pname"] = $pname;
$response["plastname"] = $plastname;
$response["drug"] = $drug;
$response["time"] = $time;
$response["minute"] = $minute;
$response["amount"] = $amount;
$response["op"] = $op;
}
//echo"Drug: ".$drug;
//echo"Hour: ".$time;
//echo"Minute: ".$minute;
//echo"Op: ".$op;
?>
Basically just get the input from Arduino: dname, dlastname, pname, and plastname. And then search the whole table. If these four columns match, just download the whole information of that row from Mysql database.
Two question: 1. If there is no problem with php script, how should write the code in Arduino yun 2.How to download data from php file? Is there something like a return so that I can get all data in Arduino Yun?