user3008755 user3008755 - 1 year ago 98
MySQL Question

How to loop the query in this case?

I have been trying to loop this query but all I get is the first value.

When I do the same command in workbench I get all the values.
What am I doing wrong here? Any answers are much appreciated!

global $db;
$stmt12 = $db->query('SELECT `Value` FROM overriddenpropertyvalues WHERE ParentGUID LIKE "' . $itemguid . '";');
$propertyvaluerow = $stmt12->fetch();
while ($propertyvaluerow != null) {


You are fetching only one value with ->fetch(). That's why you receive only one value.

Example from here:

$query = $db->prepare('SELECT `Value` FROM `overriddenpropertyvalues` WHERE ParentGUID LIKE :like');

$query->execute([':like' => $itemguid]);


while ($query->fetch()) {
    echo $value."<br/>"