I have a string like this: $shortName = 'DATE,FB,DS,AK,GB,AJ,GL';
Now I want to create variables like $DATE $FB $DS $AK $GB $AJ $GL dynamically for passing these variables into bind_result() function.
here is my code
$gameQuery = "SELECT `SHORT` FROM `game` WHERE `STATUS` = 1"
$gameStmt = $this->game->prepare($gameQuery);
$gameStmt -> execute();
$gameStmt -> bind_result($short);
$shortName = 'DATE';
while ($gameStmt->fetch()) {
$shortName = $shortName.','.$short;
}
echo $shortName; #output : DATE,FB,DS,AK,GB,AJ,GL
$chartQuery = "SELECT $shortName FROM `chart` WHERE MONTH(`date`) = ?";
$chartStmt = $this->chart->prepare($chartQuery);
$chartStmt -> bind_param("s",$month);
$chartStmt -> execute();
$chartStmt -> bind_result();
Does anybody have a solution or an alternative for this ?
$shortNamestore every$shortand after while loop end i am using in other query ..