We have one requirement similar to google forms, which will send the data to google Sheets.
Using PHP we built a web app(which acts like a google form that collects data from users eg Name, Email, etc) that will send output data(submits Multiple output responses in a single submit click ie array of responses, eg. output.1:- Name: john, Email: [email protected], etc and output.2:- Name: sam, Email: [email protected], etc ) to the database, now the task is, we need to send the same data to google sheets using google sheets script URL instead of the database.
This is the code that we used to insert the web app’s array of output data into the database
<?php
insert.php
$connect = new PDO("mysql:host= localhost;dbname= ","user name","password");
$query = "
INSERT INTO expense
(first_name, last_name, Category)
VALUES (:first_name, :last_name, :Category)
";
for($count = 0; $count<count($_POST['hidden_first_name']); $count++)
{
$data = array(
':first_name' => $_POST['hidden_first_name'][$count],
':last_name' => $_POST['hidden_last_name'][$count],
':Category' => $_POST['hidden_Category'][$count]
);
$statement = $connect->prepare($query);
$statement->execute($data);
}
?>
So, we need the same kind of code which has to have the ability to send the obtained multiple output data ie array of responses (eg. output.1 : Name: john, Email: [email protected], etc and output.2: Name: sam, Email: [email protected], etc from single submit click) from the web app to google sheet.