3s2ng Posted October 4, 2006 Share Posted October 4, 2006 Hello Freaks,I want to create a page like http://www.royalgojiteam.com/recognition_advancements.php but no database only CSV file. How can I manage a page like that? The page is categories based on 1 field in the CSV in this case it the Title(ex. Royal Ambassadors, Ambassador V, etc.)Sample Xls file:[table][tr][td]Primary Last Name[/td][td]Primary First Name[/td][td]Secondary Last Name[/td][td]Secondary First Name[/td][td]Email[/td][td]Title[/td][td]State[/td][td]Password[/td][/tr][tr][td]McEachern[/td][td]Keith[/td][td]Secondary Last Name[/td][td]Secondary First Name[/td][td][email protected][/td][td]Royal Ambassador IV[/td][td]CT[/td][td]pwd[/td][/tr][tr][td]Estong[/td][td]Capio[/td][td][/td][td][/td][td][email protected][/td][td]Royal Ambassador[/td][td]AZ[/td][td]123[/td][/tr][/table]Sample CSV Primary Last Name,Primary First Name,Secondary Last Name,Secondary First Name,Email,Title,ST,PasswordMcEachern,Keith,,,[email protected],Royal Ambassador IV,CT,km5555Moreland,Keith,,,[email protected],Royal Ambassador IV,CO,klmsmmHow can I parse the csv to be placed in that kind of layout?Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/22940-csv-parser/ Share on other sites More sharing options...
AndyB Posted October 4, 2006 Share Posted October 4, 2006 file() reads the file into an arrayexplode("," ...) will explode each line into separate elements Link to comment https://forums.phpfreaks.com/topic/22940-csv-parser/#findComment-103514 Share on other sites More sharing options...
3s2ng Posted October 4, 2006 Author Share Posted October 4, 2006 Thanks for the Reply AndyB.I want to display categorically. Like if 1 listing has a title "Ambasador" I want to get that line and save it in an array. So it will display all listings with title "Ambassador" in the Ambassado category. Link to comment https://forums.phpfreaks.com/topic/22940-csv-parser/#findComment-103526 Share on other sites More sharing options...
3s2ng Posted October 4, 2006 Author Share Posted October 4, 2006 up please Link to comment https://forums.phpfreaks.com/topic/22940-csv-parser/#findComment-103674 Share on other sites More sharing options...
obsidian Posted October 4, 2006 Share Posted October 4, 2006 as long as you're not using incredibly large CSV files, you'll be fine. you'll still have to parse through each record to sort since there is no engine within a flat file to sort by or filter. check out fgetcsv() as well:[code]<?php$handle = fopen("test.csv", "r");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]hope that helps Link to comment https://forums.phpfreaks.com/topic/22940-csv-parser/#findComment-103678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.