Jump to content

PHP MySQL CSV problem


Mike SD

Recommended Posts

Hello Everyone

 

I was hoping someone could help me with a PHP MySQL CSV problem

 

I am trying to create an online add-on for a program I use called ScheduleIt

I export all of the data from the ScheduleIt program as a .csv file and import this into a MySQL database, then use PHP to display selected data

 

The problem I am having is with the dates

When exporting the data as a .csv file it exports the dates as general formatted text (2009/05/05 becomes 39938)

 

I can open the .csv file in Excel and format the cells using a custom format (yyyy/mm/dd) then upload the data to my database

But I want to eliminate this section

 

I am trying to create some sort of code to format the dates

It does not matter when the dates are formatted, all I want to do is search the database for a chosen date

 

Does anyone know how this can be done?

I have been searching the internet for weeks and have made no progress

 

Thank you for your time

 

Regards

Michael

Link to comment
https://forums.phpfreaks.com/topic/156924-php-mysql-csv-problem/
Share on other sites

Any code?

 

What code do you need?

 

To import my .csv into my database I use:

$sql = 'LOAD DATA LOCAL INFILE \'temp/schedule.csv\' REPLACE INTO TABLE `table` FIELDS TERMINATED BY \',\' ENCLOSED BY \'"\' ESCAPED BY \'\\\\\' LINES TERMINATED BY \'\\r\\n\'
. ' '; 
$result=mysql_query($sql);

 

To to display the data by date I use:

$sql="SELECT * FROM $tbl_name WHERE DateStart <= '$filter' && DateEnd >= '$filter' ORDER BY ResourceName ASC";

 

Does this help?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.