troubleshooting Question

Grouping result's output? PHP, SQL

Avatar of gisvpn
gisvpnFlag for United States of America asked on
HTMLPHPSQL
2 Comments1 Solution153 ViewsLast Modified:
Hi All,

I have a simple list of results extracted and outputted to the page like this:

$sql_qry_tsk = "SELECT * FROM main WHERE tsk_meeting='$qry_e24' ORDER BY tsk_date DESC ;";
$result_qry_tsk = $conn_show_actions->query($sql_qry);


    if ($result_qry_tsk ->num_rows > 0) {

      while($row = $result_qry_tsk->fetch_assoc()) {

        $qry_tsk_nme = $row["tsk_nme"];
				$qry_tsk_date = $row["tsk_date"];
       
        
        echo "$qry_tsk_date - $qry_tsk_nme<br>";
        }
        
        } else {
        
        echo "No results.";
        
        }


I would like to output these results but group by the tsk_date so for example if I had these results for tsk_date instead of outputting them in the list (as below, as they currently do):

2018/08/25 - a result's name
2018/08/25 - a result's name
2018/08/25 - a result's name
2018/08/24 - a result's name
2018/08/24 - a result's name
2018/08/23 - a result's name
2018/08/23 - a result's name
2018/08/23 - a result's name
2018/08/20 - a result's name
2018/08/20 - a result's name

I instead would like:

Saturday - 8/25
2018/08/25 - a result's name
2018/08/25 - a result's name
2018/08/25 - a result's name

Friday - 8/24
2018/08/24 - a result's name
2018/08/24 - a result's name

Thursday - 8/23
2018/08/23 - a result's name
2018/08/23 - a result's name
2018/08/23 - a result's name

Monday - 8/20
2018/08/20 - a result's name
2018/08/20 - a result's name

How would this be approached?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros