I wrote a script to download a google sheet, and then upload this sheet to my dadabase.
Everything seems to be working fine except that the data is now being uploaded to my database.
I navigated to the folder and then ran this command:
php -f updatedatabase.php
This is the script I wrote (the googel sheet key is filled in with the actual key--i tested the link and it is working, and the database credentials have been starred out for security reasons):
<?php
$datas = file_get_contents("https://docs.google.com/spreadsheets/d/1fOe2fz8PmYzTWU7l_KboHdv0zP0KZkhcJUTGJDUXaKk/gviz/tq?tqx=out:csv&sheet=All%20Items&range=A:G");
$datas = explode( PHP_EOL, $datas );
//FORMAT ("Name1", "Image1", "Description1", "Rarity1", "Price1", "Status1", "Store1"), ("Name2", "Image2", "Description2", "Rarity2", "Price2", "Status2", "Store2").....
// Info to connect to the database
$servername = ".com";
$dbusername = "";
$password = "!19";
$dbname = "";
$con=mysqli_connect( $servername, $dbusername, $password, $dbname );
mysqli_query( $con, "TRUNCATE TABLE Items" );
foreach ( $datas as $data ) {
echo $data . "\n";
mysqli_query( $con, "INSERT INTO Items (Name,Image,Description,Rarity,Price,Status,Store) VALUES " . $data );
}
mysqli_close($con);
?>