I have been trying to do the following: I have stored subjects in database seperated by commas to make an array. I am then running a foreach loop to get the subjects once they have been exploded. The part where i am stuck is I am trying to create variables based on the subject names to then run a mysqli code that will derive information from another table in DB Based on the subject name that i should be setting.
I've tried using eval, which does not display anything when i run the code.
$hwvar = "";
$hwsubject = "";
foreach ($hwarray as $hwvar) {
eval("$hwvar = $row".""."['$hwvar']");
}
?>
<td><?php echo $hwvar; ?></td>
so i need the loop to produce the following for each item is loops through ($sujectname is what is stored and derived from the database e.g homework1) $subjectname = $row['$subjectname'];
<td><?php echo $hwvar; ?></td>inside the loop and forget about all this EVAL() nonsense. As you have it now, the output would only get the LAST data item in the array anywayeval()is evil