I am new to javascript so please be patient with me. I have a function in php which goes like this:
public function getSubjects() {
$stmt = $this->_db->prepare('SELECT id, subject from subjects');
$stmt->execute();
return $stmt->fetchall();
}
Then I have a variable subs in javascript which is hardocded like this:
var subs = {"Maths":1,"Geography":2,"Chmesitry":3,"Literature":4};
How do I populate the subs variable with the format above from the getSubjects method?
json_encodemy friend... jay-son-en-code.... php.net/manual/en/function.json-encode.phpChmesitry;)