Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "raspberry";
- $dbname = "hackathon";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT token,distance FROM deplacement";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $dist = intval($row["distance"]);
- echo "token: " . $row["token"]. " - total de points: " . $dist. "<br>";
- //1€ = 100KM
- //1 point = 1 cent
- //100 points = 1€ = 100KM
- //1 points = 1 KM
- if ($dist>1000){
- $points = intval(floor($dist/1000));
- echo $points;
- $url = 'http://eco.cslabs.be/points/add/';
- echo $url;
- $data = array('amount' => $points, 'token' => $row["token"]);
- var_dump($data);
- // use key 'http' even if you send the request to https://...
- $options = array('http' => array('method' => 'POST','content' => http_bui$
- var_dump($options);
- $context = context_create_stream($options);
- // $result = file_get_contents($url, false, $context);
- $fp = fopen($url, 'r', false, $context);
- /* if ($result === FALSE) {
- echo "error";
- }
- */
- var_dump($fp);
- }
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement