table clients
has 29 columns.
as an example, wi'll take five of them:
earth, sun, moon, jupiter, venus
row id=1
has the following values:
blue, gold, silver, lessons, arts
function giveme_vars($id){
global $db;
$sql = "select * from clients where id = :aid";
$st = $db->prepare($sql);
$st->execute([
":aid" => $id
]);
$row = $st->fetch();
// here I need something like this:
foreach($row as $key=>$val){
$variable_key = $row_value;
//then make all of them global;
}
}
As a result I'm expecting:
$earth = 'blue';
$sun = 'gold';
$mon = 'silver';
$jupiter = 'lessons';
$venus = 'arts';
All of the variables should be global
i.e. accessible for all files on the server.
Any help?