php - Using $row result in a variable name -


contid db gives number, number want put on end of varible, tried gives blank page

if take

"" . $row['contid'] . "" 

out fine , page loads fine, know wrong way cant think of how other way, heres code...

$object = new connecttodb(); $result = $object->getmarks($user,$ksget);  foreach($result $row){      $marks"" . $row['contid'] . "" = "" . $row['mark'] . "/5"; } 

the result db give 7 rows contid number between 1 , 7

an array smarter idea variable variables

$marks=array(); foreach($result $row){      $marks[{$row['contid']}]  =  $row['mark'] . "/5"; } 

Popular posts from this blog