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 ;
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
php mysql excel cron csv
Muddasir abbas
source share