I have been looking all over Stack Overflow and the PHP documentation for an answer to this. So far every time I have tried the example I have gotten a server error or the query failed. This PHP file should be able to perform two functions:
Print out CSV formatted data from all the data in the column called DeviceName in the table with a name of the $tourcode.
Do the same, but with the table StoredTours and the column StoredTourName.
Once the CSV formatted output is printed, I will then use it in a spinner or list picker for the app.
Picture of Database with the name 801929
Here is the Code I have so far with the $action value in the URL being the variable to control what the file does.
<?php
$DBUSER = 'clientapp';
$DBPW ='///PASSWORD///';
//$DBPW = $_GET['passwd'];
$DBHOST = 'localhost';
$DBNAME = '///DBNAME///';
$dbc = mysqli_connect($DBHOST,$DBUSER,$DBPW,$DBNAME);
if (!$dbc) {
die("Database connection failed: " . mysqli_error($dbc));
exit();
}
//$tourcode = $_GET['tourcode'];
//$action = $_GET['action'];
$tourcode = '801929';
$action = 'devices';
if ($action === 'devices') {
/* Here I want to print all the values in the column called
DeviceName form the table whose name is = $tourcode */
} else if ($action === 'tours') {
/* Do the same as above, but with the table being
StoredTours and the column called StoredTourName */
}?>
It would be very helpful if someone could help me do this.