I have created this
while ($data = mysqli_fetch_array($course_result, MYSQLI_ASSOC)) {
print_r($data['course']);
}
Which prints this:
Array (
[user_id] => 57
[course] => 6
)
Array (
[user_id] => 57
[course] => 5
)
How can I create two variables that are equal to the values of the 'course' fields.
So ideally, variable x ends up equalling to 6 and variable y equals 5 (essentially what I'm asking is how to extract the value from the mysql arrays and putting it into a variable)?
6/5, or will it always be 1st result asxand 2nd result asy, and will there always just be 2 rows returned?while ($data = mysqli_fetch_array($course_result, MYSQLI_ASSOC)) { if(!isset($x)){$x=$data['course']['course'];}else{$y=$data['course']['course'];} }. This assumes only 2 rows returned from your query, and that it is only called once, as once$xis set, it won't be reset, and$ywould continue to be reset.