Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/302518-php-csv-search-form/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/302518-php-csv-search-form/#findComment-1539294
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/302518-php-csv-search-form/#findComment-1539296
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.