1

I want to calculate birthdays by php using an excel database then congrat them when it`s close to their birhday . the database contain 700 birth days, now here is my questions 1. is it possible to use excel database or should i convert is mysql 2. how can you give me an idea about how it works(how to receive data from excel)

Omid
  • 438
  • 4
  • 11

3 Answers3

0

What you can do is convert excel into xml and read data using PHP.

More info regarding SimpleXML :- http://www.w3schools.com/php/php_xml_simplexml.asp

Read and write Excel data in PHP :- http://www.ibm.com/developerworks/library/os-phpexcel/

Hope this helps. Cheers!

Anjana Silva
  • 8,353
  • 4
  • 51
  • 54
0

I would use google search to find these two options that are both on StackExchange:

Upload Excel spreadsheet to SQL Database convert excel worksheet to sql script

Reading an Excel document with PHP Reading an Excel file in PHP

Community
  • 1
  • 1
nwolybug
  • 462
  • 5
  • 12
0

According to your needs this should be the easiest way to achieve your goal. You Excel file should have this structure:

Friend A    12/08/2014  a@mail.com
Friend B    12/08/2014  b@mail.com
Friend C    08/08/2014  c@mail.com
Friend D    13/08/2014  d@mail.com
Friend E    14/08/2014  e@mail.com
Friend F    02/09/2014  f@mail.com

The first column contains his/her name, the second one the birthday and the third one contains his/her email address.

Save your Excel file as Text (Tab delimited). Place this file birthdays.txt in the same directory with a file containing the PHP snippet shown below

<?php
$handle = @fopen("birthdays.txt", "r");
if($handle){
    while (($buffer = fgets($handle, 4096)) !== false){
        $line = explode("\t", $buffer);
        if(date('d/m/Y') == date('d/m/Y', strtotime($line[1]))){
            mail($line[2], 'Happy birthday!', 'Dear ' . $line[0] .', I wish you all the best!');
        }
    }
    fclose($handle);
}
?>

And run this file once daily, manually or using Crontab like this (five minutes after mighnight in this case)

5 0 * * * php /full-path-to-your-script/birthdays.php

That's it. As you can see there's no need for any external libraries.

hex494D49
  • 9,109
  • 3
  • 38
  • 47