Search code examples
phpmysqlformsgoogle-forms

PHP to MySQL and Google sheet?


A few months ago, my supervisor needed me to create a form to collect some data - at the time, the most sensible thing to do was just to whip together a Google Form, no problem. Now it turns out that the data collection program needs to expand, and it makes more sense to direct the form to a MySQL database (using PHP) instead - again, no problem, already done. However, for reasons I won't elaborate on here, my supervisor still wants that data to go to the original Google Sheet as well.

My question - is it possible to submit form data to two separate sheets when one is a MySQL table and the other is a Google Sheet?

Thanks!


Solution

  • I know that feel bro ;)

    There's some resources to handle boss requests:

    1. PHPExcel Class is a library written in pure PHP and providing a set of classes that allow you to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, HTML...
    2. You will need an script to process the outputs.
    3. Excel / CSV > MySQL
    4. MySQL > Excel / CSV

    If you need directly to work with Google Docs, you will have to follow the previous steps and play with the following project:

    php-google-spreadsheet-client is a library that provides a simple interface to the Google Spreadsheet API.

    You will need to store data in MySQL and pass it to Google.

    Second idea:

    If your boss neet it NOW, you can give a chance to Zapier and do it fast. If you don't need a very fast sync time, it can be a good free option.

    I hope it helps :)