Send email through Cron every day with a backup copy of the csv / xls or xml database using php on a Linux server

This is the first time I'm trying to tune Cron to work. I need your help. I have db data in the csv / xls file, but I don’t know how I can install the cron task once on a daily basis with this file by email along with the data.

Database table with data

DROP TABLE IF EXISTS `student`; CREATE TABLE `student` ( `id` int(11) NOT NULL auto_increment, `name` varchar(32) NOT NULL, `major` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ; -- -- Dumping data for table `student` -- INSERT INTO `student` VALUES (1, 'John', 'Computer Science'); INSERT INTO `student` VALUES (2, 'Victor', 'Multimedia'); INSERT INTO `student` VALUES (3, 'Tomy', 'Networking'); INSERT INTO `student` VALUES (4, 'Will', 'Database'); INSERT INTO `student` VALUES (5, 'Jacky', 'Techincal'); 

data.php

 <table border="1"> <tr> <th>NO.</th> <th>NAME</th> <th>Major</th> </tr> <?php //connection to mysql mysql_connect("localhost", "root", ""); //server , username , password mysql_select_db("codelution"); //query get data $sql = mysql_query("SELECT * FROM student ORDER BY id ASC"); $no = 1; while($data = mysql_fetch_assoc($sql)){ echo ' <tr> <td>'.$no.'</td> <td>'.$data['name'].'</td> <td>'.$data['major'].'</td> </tr> '; $no++; } ?> </table> 

export.php

 <?php // The function header by sending raw excel header("Content-type: application/vnd-ms-excel"); // Defines the name of the export file "codelution-export.xls" header("Content-Disposition: attachment; filename=codelution-export.xls"); // Add data table include 'data.php'; ?> 

and finally you need this codelution-export.xls full code file

+1
php mysql excel cron csv
source share

No one has answered this question yet.

See similar questions:

8
Daily database backup using Cron job

or similar:

380
Send an email using the GMail SMTP server from the PHP page
117
Running a cron job on Linux every 6 hours
92
Running PHP file in cron job using cPanel
45
Cron every three days
4
Cron task to backup database in linux / php
2
Send email: Cron job
0
Backup PHP MySQL Database
0
Archiving a MySQL live database database
-one
Vb.net error for query and database
-2
Sending email using cron?

All Articles