PHP 7 and MySQL. I want to take a set of labels stored in the database and individually place each label in its own session variable so I can use them as tab labels in my application.
I can retrieve the data and echo it but the corresponding session variables all show a not set status.
<?php
require_once('dbconnect.inc.php');
$_SESSION['histopic'] = "dash";
$numnames = 100;
for ($i = 1; $i <= $numnames; $i++) {
$stmt = $pdo->prepare('SELECT hislabelsName FROM hislabels WHERE hislabelsID = ?');
$temp = $i;
$stmt->execute(array($temp));
$result = $stmt->fetchALL();
foreach ($result as $row) {
$_SESSION['hislabelsName$i'] = $row["hislabelsName"];
}
echo $_SESSION['hislabelsName$i'] . "<br>";
echo $_SESSION['hislabelsName5'] . "<br>";
}
echo $_SESSION['hislabelsName5'];
produces an undefined index error.
How do I fix this?
TIA.