KJS KJS - 1 year ago 76
MySQL Question

Dynamic $row output from array

I am trying to achieve dynamic $row values from an array, and show them as output. It keeps showing nothing while the values are already there.

This is what I have so far, where:

should return:


'it' is the $val from the array.

foreach($arrMapCookieToLang as $key => $val) {
$shrtKey = $row["lg_".$val.""];

<input type="text" name="lg_$val" value="$shrtKey">

Anyone an idea?

Answer Source

What you have should result in a syntax error. Try the following:

foreach($arrMapCookieToLang as $key => $val) {
    $shrtKey = $row['lg_'.$val];
    <input type="text" name="lg_<?= $val ?>" value="<?= $shrtKey ?>">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download