This is my database:
Am trying to get all from_id which to_id is 4 to a json object where ill be able to show all messages from a from_id in a stack sorted by their different time_sent
I have tried:
CODE:
PHP STATEMENT THAT GETS DATA FROM DATABASE IS AN OBJECT ORIENTEND:
public function getadminMessage(){
$sql = "SELECT group_concat(messg, time_sent, from_id) as from_id from
messages where to_id = 4 group by from_id";
retu $this->db->fetchAll($sql); //db is in my dbase class
}
THE FETCH ALL
public function fetchAll($sql){
$result = $this->query($sql);
$out = array();
while($row = mysqli_fetch_assoc($result)){
$out[] = $row;
}
mysqli_free_result($result);
retu $out;
}
THE QUERY
public function query($sql){
$this->_last_query = $sql;
$result = mysqli_query($this->_codb, $sql);
$this->displayQuery($result);
retu $result;
} // end of query
I then use getjson
$.getJSON("http://127.0.0.1/tum_old/custom/php/getadminmsg.php",
function(response){
console.log(response);
});
On my log i get
The data seems group concatenated but i would also like the various messages to be in object form that is the messages to be displayed as objects such that i can easily do:
data.object[0].from_id[0].msg to get TRUE LOVE as the message


