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]keithmceachern@aol.com[/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]test@aol.com[/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,,,keithmceachern@aol.com,Royal Ambassador IV,CT,km5555Moreland,Keith,,,free4lifekm@ris.net,Royal Ambassador IV,CO,klmsmmHow can I parse the csv to be placed in that kind of layout?Thanks in advance. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
3s2ng Posted October 4, 2006 Author Share Posted October 4, 2006 up please Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.