0

After I use var_dump($rows); I get result from query as below:

object(stdClass)#11 (2) {
  ["id"]=>
  string(1) "1"
  ["name"]=>
  string(5) "riski"
}

but the result gives error

Notice: Array to string conversion

in this line :

foreach($rows as $val){
    $user .=  '<option value="'.trim(addslashes($val->id)).'">'.trim(addslashes($val->name)).'</option>';
}

How to convert the result to foreach result?

NoNaMe
  • 6,020
  • 30
  • 82
  • 110
Riski Febriansyah
  • 335
  • 1
  • 8
  • 21

1 Answers1

1

Please watch your array carefully. It is an associative array not a multidimenstional associateive array.

Try This:

$rows->id
akhilp2255
  • 330
  • 3
  • 13