Hey everyone, I am working on a project for ranking employees in my job. Basically I have a .csv output file that lists the revenue results for each person for the week. Basically what I want to do is have a field where I can upload the weekly report then the script reads that file and parses the data. Then I would use the data to award points to each person. So basically I would take that parsed data from each field and write to my sql database. so... : if ($revenue >= '1500') { ##query to write value to sql database ## } if ($close_rate >= '0.15') { ##query to write value to sql database ## } if ($hoursworked>= '32') { ##query to write value to sql database ## } Code (markup): In the csv file each line if for a different employee, so I would run the script in a loop to go through all the employees. Thats the goal so does anyone have an idea of what functions or code I can use to accomplish this? Any help would be appreciated! Thanks
so did some further research and found this code from php.net <?php $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); } ?> Code (markup): That will display the contents from a csv file so no reason I cant modify that so instead of echo'ing $data[] near the end that it compares that value in the 'if' statements like I mentioned... back to work
look at this example http://www.chipmunk-scripts.com/board/index.php?forumID=43&ID=9602 Just use the data[0] (value 1 ) to compare if it can be insert in to the database greetings