I'm using the following code to grab a csv file from one website & keep it on my website. The code is working fine.
Code: Select all
<?php
$url = 'http://thewebsite.com/export.aspx?type=csv&report=nameofthereport~8~';
$path = '/home/path/to/mywebsite.com/public_ftp/incoming/nameofthereport_Area_8.csv';
$fp = fopen($path, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
?>Code: Select all
<?php
include("/home/path/to/mywebsite.com/public_html/db_connect.php"); //connect to the database
$today = date('Y-m-d');
$query1=("SELECT * FROM `table_name` WHERE expiry > $today");
$result1=mysqli_query($GLOBALS["___mysqli_ston"], $query1);
$num1=mysqli_num_rows($result1);
if ($num1 > 0) {
while ($data = mysqli_fetch_array($result1)){
$email_to = $data["email"];
$district = $data["district"];
$report = $data["report"];
}
}
?>Could you show me the code please? Thanks.