I've got a 'contact' table in my database which stores the emails people are sending to me. In my adminpanel I'd like to order them by status. My contact table has an 'answered' INT column which updates as soon as I'm replying to them. Once I answered the email, the 'answered' will be set to '1' in the database.
As I said, I'd like to order the emails in my adminpanel by the 'answered' status. So all emails which arnt answered yet ('0' in database) should be on top and the emails I already have answered ('1' in database) should be on the bottom.
This is how I've currently got it:
$showTheEmails = array();
$getEmails = mysqli_query($mysqli,"SELECT * FROM contact ORDER BY 'answered' ASC") OR die (mysqli_error($mysqli));
if (mysqli_num_rows($getEmails) > 0){
while($row = mysqli_fetch_array($getEmails)){
$row = array(
'contact_id' => $row['contact_id'],
'name' => $row['name'],
'email' => $row['email'],
'subject' => $row['subject'],
'timestamp' => $row['timestamp'],
'answered' => $row['answered'] );
$showTheEmails[] = $row;
}
}
And ofcourse the code what displays the array.
Problem is: it's not ordering correctly. What am I doing wrong? :(