I want to write a php program to do the following:
DB: shirt_sales
shirts | color
tshirt | white
tshirt | white
tshirt | white
tshirt | blue
tshirt | blue
tshirt | black
tshirt | black
tshirt | yellow
tshirt | red
I want to query the db and have it select tshirts then list the top 3 colors sold on my web page. The result should look like:
- white
- blue
- black
I'm not sure how to write the part where the colors are counted and listed in order by sales.
$query = "SELECT shirts,color FROM shirt_sales WHERE shirts='tshirt'";
$result = mysqli_query($cxn,$query) or die ("Couldn't execute query.");
//Not sure what to write after this.