Add values from db to array, sort and display
<p>I am getting some values from a mysql database, but the values in the db are not in order. I want to order the days of the week as SUN, MON, TUE, etc. and display the corresponding values from the db table. I am currently displaying the values from the db without sorting. And I add the values to an array. How can I sort and show the values in an html table? This is my code</p>

<pre><code>&lt;?php 
$q3 = mysqli_query($link,"SELECT * FROM stores_op_hours WHERE Store_Id='$stid' ");
?&gt;
&lt;table class="table ophours"&gt;
    &lt;thead class="thead-inverse"&gt;

        &lt;tr&gt;&lt;th&gt;Day&lt;/th&gt;&lt;th&gt;Open Time&lt;/th&gt;&lt;th&gt;Close Time&lt;/th&gt;&lt;/tr&gt;
    &lt;/thead&gt;
&lt;?php 
$myarray = array();
while($rw = mysqli_fetch_array($q3)){

    $day = $rw['Day_Name'];
    $op = $rw['Open_Time'];
    $cl = $rw['Close_Time'];
    //$day = strtoupper($day);

    $myarray[] = array("day" =&gt; $day, "open" =&gt; $op, "close" =&gt; $cl);
?&gt;  
    &lt;tbody&gt;
        &lt;tr&gt;&lt;td&gt;&lt;?php echo $day; ?&gt;&lt;/td&gt;&lt;td&gt;&lt;?php echo $op; ?&gt;&lt;/td&gt;&lt;td&gt;&lt;?php echo $cl; ?&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;/tbody&gt;
&lt;?php
}
?&gt;
&lt;/table&gt;
</code></pre>