Let's say I have a table with a specific ID (quiz id) and another data cell called diff
which is the time in seconds it took to complete that quiz and put it in the DB.
I have this:
$doCommonQueryDiff = $mysqli->query("SELECT AVG(diff) FROM submissions WHERE quiz_id=$id")->fetch_array() or die($mysqli->error);
Later, when I do this to get the most common (or average?) of the data set, you will get the average of the all of the quizes it took in seconds.
I echo it using: $doCommonQueryDiff['diff']
but I get: Notice: Undefined index: diff
even though diff
is in the database as a column.