The while loop gets DB rows as such:
while($row = $result->fetch_assoc()){
$metadata_field74[] = $row['field74'];
$metadata_field75[] = $row['field75'];
$metadata_field76[] = $row['field76'];
$metadata_field77[] = $row['field77'];
}
Those rows are based on another DB table. Basically this loop should get the rows as based on another array of values received from a DB query.
Those values (field74, field75, etc) are stored in a array $metadata_id_basic[]. I get the values from that array like this and insert into the while loop:
while($row = $result->fetch_assoc()){
foreach ($metadata_id_basic as $value){
$ref = '$metadata_'.$value.'[] = $row[\''.$value.'\'];';
echo $ref;
}
}
However the array of rows is not seen. If I print $ref out it looks like:
$metadata_field74[] = $row['field74'];
$metadata_field75[] = $row['field75'];
$metadata_field76[] = $row['field76'];
$metadata_field77[] = $row['field77'];
So why does the while loop not read it correctly?
$ref = '$metadata_'.$value.'[] = $row[\''.$value.'\'];';- it's a quotes issue. Variables only get parsed in double quotes, or concatenated. So this$metadata_never gets parsed. So try removing the quotes$metadata_.$value. .....or wrap the declaration in double quotes. You may need to do a few other modifications, but that should get you started.$metadata_id_basicwhere are you referencing$rowhow does that$rowrelate to$metadata_id_basic?'$metadata_'.$value.'[] = $row[\''.$value.'\'];';what is that all about.