chia4 Posted November 12, 2016 Share Posted November 12, 2016 Basically I have some info such as a person's name, a ID#, and a time. All this info is going to be in a google spreadsheet i plan to have it connect with php and it reads it as a csv file. I want someone to put there ID# in a search form and it return the time matching there ID# any1 have any help for this? i know how to strictly make a search form, but never one reading off csv data. Thanks any help is appreciated. If any1 knows any other way to achieve what im asking for, keeping in mind it must originate from a google sheet, that would help aswell.Thanks! Quote Link to comment Share on other sites More sharing options...
requinix Posted November 12, 2016 Share Posted November 12, 2016 If you can read it as a CSV then you can get it as an array, with either fgetcsv or str_getcsv depending. Then all you need is a foreach loop. Quote Link to comment Share on other sites More sharing options...
chia4 Posted November 14, 2016 Author Share Posted November 14, 2016 So i have this <?php $url = "https://docs.google.com/spreadsheets/d/1gn8ZBepUSKbS9JlP7nRdL2StARH6d88QbA89EJgYRCQ/pub?gid=968704782&single=true&output=csv"; $row=0; if (($handle = fopen($url, "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); } However i need it to search Column B using the "Search Function" so basically someone inputs their name that is in column b. And return column D & E in that row only Quote Link to comment Share on other sites More sharing options...
requinix Posted November 14, 2016 Share Posted November 14, 2016 You've managed to copy the code from the fgetcsv documentation so you have that much working correctly. Next step is to write the code that does the "search" according to the values in $data: if the value matches then do whatever, if not then don't do whatever. 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.