I have the following that returns data from my table...
$query = dbConnect()->prepare("SELECT * FROM users a INNER JOIN actions b ON a.id = b.user_id WHERE a.id=:user_id");
$query->bindParam(':user_id', $_SESSION['user_id']);
$query->execute();
if($row = $query->fetchAll()){
$row['id'] = $_SESSION['user_id'];
}
I want to print out every value in my 'check_id' column for the currently logged in user...
I've tried...
if($row = $query->fetchAll()){
$row['id'] = $_SESSION['user_id'];
$checkValue = $row['check_id'];
}
Only i receive...
Notice: Undefined index: check_id in /home/index.php on line 24
Printing the array shows my check_id value...
You need to;
$arrResults = $query->fetchAll();
foreach($arrResults as $result) {
echo $result['user_id'] . PHP_EOL;
}
To debug use print_r
if($row = $query->fetchAll()){
print_r($row);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.