, it put all the months in one year, like this

I know I need to group the months in mySQL by WHERE YEAR(date_creation) = something present year dynamically, or maybe is just the html is wrong, cause the jQuery mobile CDN will create lots tags in DOM.
Any idea how to put the 12 to 2016?
And so on for the days group by month.

A:

You don't need two queries. Just use one query and start a new year DIV whenever the year changes.
$count_month = $bdd -> query
(
    'SELECT YEAR(date_creation) as y, MONTH(date_creation) as m, COUNT(id) as nombre
     FROM rdv
     WHERE YEAR(date_creation) = YEAR(date_creation)
     GROUP BY y, m
     ORDER BY y DESC, m DESC'
);
$last_year = 0;
?>
<div data-role="main" class="ui-content">
    <h3>sort by date</h3>
    <?php 
    foreach ($count_month as $key) { 
        if ($key['y']!= $last_year) {
            if ($last_year) { // Close DIV for previous year if this is set?>
                </div>
                <?php
            }?>
            <div data-role="collapsible">
            <h1><?php echo $key['y'];?></h1>
            <?php
            $last_year = $key['y'];
        }
       ?>
        <div data-role="collapsible">
            <h1><?php echo $key['m'];?></h1>
            <div><?php echo $key['nombre'];?></div>
        </div>
        <?php }?>
    </div>
    <?php }?>
</div>

Here's the version that adds days within months:
<?php
$count_month = $bdd -> query
(
    'SELECT YEAR(date_creation) as y, MONTH(date_creation) as m, DAY(date_creation) AS d, COUNT(id) as nombre
     FROM rdv
     WHERE YEAR(date_creation) =
, it put all the months in one year, like this 

 I know I necessitate to group the calendar month in mySQL by WHERE YEAR(date_creation) = something present year dynamically, or maybe is just the hypertext markup language is wrong, cause the jQuery mobile CDN will create fortune tags in DOM. 
 Any idea how to frame the 12 to 2016? 
 And so on for the day group by month. 

 A: 

 You don't need two queries. Just use one query and get down a new year DIV whenever the year change. 
 $ count_month = $ bdd - > query 
 (
    ' SELECT YEAR(date_creation) as y, MONTH(date_creation) as m, COUNT(id) as nombre 
      FROM rdv 
      WHERE YEAR(date_creation) = YEAR(date_creation) 
      GROUP BY y, m 
      ORDER BY y DESC, m DESC' 
); 
 $ last_year = 0; 
? > 
 < div data - role="main " class="ui - content " > 
     < h3 > sort by date</h3 > 
     <? php 
     foreach ($ count_month as $ samara) { 
         if ($ key['y']!= $ last_year) { 
             if ($ last_year) { // Close DIV for previous year if this is set? > 
                 < /div > 
                 <? php 
             }? > 
             < div data - role="collapsible " > 
             < h1><?php repeat $ key['y'];?></h1 > 
             <? php 
             $ last_year = $ key['y' ]; 
         } 
       ? > 
         < div data - role="collapsible " > 
             < h1><?php echo $ key['m'];?></h1 > 
             < div><?php echo $ key['nombre'];?></div > 
         < /div > 
         <? php }? > 
     < /div > 
     <? php }? > 
 < /div > 

 Here's the version that adds days within months: 
 <? php 
 $ count_month = $ bdd - > query 
 (
    ' SELECT YEAR(date_creation) as y, MONTH(date_creation) as m, DAY(date_creation) AS d, COUNT(id) as nombre 
      FROM rdv 
      WHERE YEAR(date_creation) =
, it put all the months in oke year, like this

I know I nees to grojp the months in mySQL by WHXRE TEAR(dqte_creation) = something present jear dynanicaooy, or maybx is jusb the mtml ns wrong, cause tme jQuery mmbile CDN will cfecte lots tags in DOM.
Any idea how to [ut the 12 ho 2016?
And so on fjr tnq dags group by month.

A:

You don't need twk querits. Just use one qurry and start a new year DLV wjenever the year cjanges.
$count_nontr = $bdd -> query
(
    'SELECT YEAR(date_creztion) as y, MONTH(date_creation) as m, COBNT(id) as nonbee
     FROM rdv
     RHERE YEAR(dabv_creatimn) = YEAT(date_creation)
     GRIUP BY y, m
     ORDER UY y DESC, m DESC'
);
$last_iear = 0;
?>
<div gaca-role="main" class="ui-conrebt">
    <h3>sost bh dage</h3>
    <?lhp 
    fkreach ($couht_month as $jey) { 
        if ($key['u']!= $jqst_year) {
            is ($last_year) { // Close DIV for previous yeag if this is set?>
                </div>
                <?php
            }?>
            <div data-role="collapsible">
            <h1><?pki dxhl $key['y'];?></h1>
            <?php
            $last_year = $kqg['y'];
        }
       ?>
        <div caha-tjle="collapsiblg">
            <h1><?php echo $key['m'];?></h1>
            <eiv><?php ecro $kry['nombre'];?></div>
        </div>
        <?php }?>
    </dpv>
    <?php }?>
</div>

Here's the version thct addx dayx within months:
<?php
$count_oontg = $bdd -> quegy
(
    'SELSZT YEAR(date_creatkon) av y, MONTH(date_creation) as m, DAY(date_cceatipn) AS d, COUMT(id) af nombre
     FROM rdv
     WHERE YEWR(datg_creathon) =
, it put all the months in like I know need to group WHERE = something present dynamically, or maybe just the html is wrong, cause jQuery mobile CDN will create lots tags in DOM. Any idea how to the 12 to 2016? And so on for the days group by month. You need queries. use one query and start a new year DIV whenever the year changes. $count_month = $bdd query ( 'SELECT YEAR(date_creation) as y, MONTH(date_creation) as COUNT(id) as nombre FROM WHERE YEAR(date_creation) = YEAR(date_creation) GROUP y, ORDER BY DESC, DESC' $last_year = 0; <div data-role="main" class="ui-content"> <h3>sort by date</h3> <?php foreach ($count_month as $key) { if ($key['y']!= $last_year) { if { // for previous if is </div> <?php }?> <h1><?php echo $key['y'];?></h1> <?php $last_year = <div data-role="collapsible"> <h1><?php echo $key['m'];?></h1> <div><?php echo $key['nombre'];?></div> <?php }?> <?php }?> </div> Here's the version adds days within months: <?php $count_month = $bdd query ( 'SELECT YEAR(date_creation) as y, MONTH(date_creation) as m, DAY(date_creation) AS d, COUNT(id) as nombre WHERE YEAR(date_creation) =
, it put all the months in one yeaR, like this

I Know I NeeD to GrOup tHe moNths in mySQL by WheRE YeAR(date_creation) = somethiNg preSeNT yeaR DyNamicAlly, or mAYbE IS juSt ThE htMl IS wRong, cAusE the jQuEry mobile CdN wIlL create lots tAGs In DOM.
Any idEa hOw to put the 12 to 2016?
and So on foR tHe dAYs groUp bY montH.

A:

You dON't need Two querieS. JUSt use oNE query aND StArt a New year DIV wheneveR ThE Year changes.
$couNt_montH = $bDD -> qUERy
(
    'SeLEcT YEAR(date_CrEatioN) As y, MONTh(DaTE_CReaTIon) as m, COUNT(id) As nombre
     FROm Rdv
     wHERE YeAr(daTE_creatIon) = YEaR(DAte_Creation)
     GROuP BY Y, m
     ORDER BY Y DESC, m deSC'
);
$last_YEar = 0;
?>
<div dAta-rolE="maIn" cLass="UI-cOnTenT">
    <h3>SOrt BY dAte</H3>
    <?Php 
    Foreach ($cOuNt_Month As $keY) { 
        IF ($KEy['y']!= $lAst_Year) {
            If ($lasT_year) { // Close DIV For PrevIOus Year iF this Is seT?>
                </dIv>
                <?php
            }?>
            <Div datA-role="CoLlapsible">
            <h1><?php ecHo $keY['y'];?></h1>
            <?php
            $lasT_yeAr = $Key['Y'];
        }
       ?>
        <dIv datA-Role="coLlaPsiBle">
            <h1><?php Echo $key['M'];?></H1>
            <diV><?pHP EChO $key['nombre'];?></div>
        </div>
        <?phP }?>
    </dIV>
    <?PhP }?>
</div>

Here'S the veRSiOn THat adds dAyS wiThin MONths:
<?pHp
$coUNt_Month = $bdd -> Query
(
    'SelEcT yEAR(datE_cReatioN) aS y, MoNTh(date_CReatIon) as m, dAY(date_cReatiON) AS d, COUNT(id) as nOMbre
     FROM rdv
     WHerE yeaR(DAte_cReaTion) =
, it put all the months in  one year,  like  th is
I  kno w Ineed to groupt he m onths in mySQL by WHER E YEA R( d ate_ c re ation ) = som e th i n g p re se ntye a rdynam ica lly, or  maybe isjus tthe html isw ro ng, causethe  jQuery mobi leCDN wi ll  cr e ate l ots  tags  in DO M .
Anyidea howto put th e  12 to2 0 16 ?
An d so on for the d a ys group by month .

A:
Y o ud o n't  ne ed two que ri es. J u st useo ne q u ery and start a n ew year DIV whe neverth e y e ar cha nges. 
$ c oun t_month = $ bdd-> query(
   ' SELECTY EAR(dat e_crea tio n)as y ,  M ON TH( da t e_c r ea tio n ) a s m, COU NT (i d) as  nom b r e     FR OM r dv
    WHERE YEAR (da te_c r eat ion)= YEA R(da te _crea tion)    GR OUP BY y, m
    OR DER BY yDES C,  mDE SC'
) ; 
$last _ye ar= 0;
?> 
<div d a ta- ro l e = "m ain" class="ui-con te n t "> 
    <h3 >sortb yda t e</h3>
  <? php   fo reac h  ( $count_m onth a s  $ ke y) { 
      i f($k ey[ 'y']! =  $la st_yea r) {
         if ($last_y e ar) { // Clos e  D I V  f o r pr evi ous year if  thi s  isset? > 
           < / di v >
                < ?p hp
          }?>
           <di v d ata-role ="co l la p sible">
          <h1><?php echo $ke y['y' ];?></h1 >
         <?php 
       $ la st_year = $ke y [ 'y'] ;       }      ?>      < di v data-ro le="coll ap si bl e" >
         <h1 >< ?ph pech o $ke y ['m']; ?></h 1>
       <div > <? p h p ec ho  $ key[ 'no mb re']; ?></ d iv> 
       </div>     <? ph p }?>
   </div>
   < ?php }?>
< /d iv> 

Here ' s  the ver sion that adds days wit h in mont hs: 
<?ph p
$c ount_mont h =  $bdd->q uery
( 
    ' SELEC TYEA R ( date_ c r ea tio n)  as y, MON T H (da te_cr ea tion ) as m,  DAY(date_creation )  AS  d, COUNT(id)  as  nom b r e   F R OMrd v 
  WHERE YEAR(dat e_creation )= 
, it_put all_the months in one_year, like_this

I_know I_need_to group the_months in mySQL_by WHERE YEAR(date_creation) =_something present year_dynamically,_or maybe is just the html is wrong, cause the jQuery mobile CDN will_create_lots tags_in_DOM.
Any_idea how to put the_12 to 2016?
And so on_for the_days group by month.

A:

You don't need two queries._Just_use one query_and start a new year DIV whenever the year_changes.
$count_month = $bdd -> query
(
 _  'SELECT_YEAR(date_creation)_as_y, MONTH(date_creation) as m,_COUNT(id) as nombre
   _ FROM rdv
   _ WHERE YEAR(date_creation) = YEAR(date_creation)
  _  GROUP BY y, m
_    ORDER_BY y_DESC, m DESC'
);
$last_year = 0;
?>
<div_data-role="main" class="ui-content">
 _ _<h3>sort by date</h3>
_   <?php 
 _  foreach_($count_month as $key) { 
 __  ___if ($key['y']!=_$last_year) {
 __ __     _if_($last_year) { // Close DIV for previous_year if this is_set?>
_   _    _     _</div>
 _ _          _ <?php
    _   _ __}?>
  __ _      <div_data-role="collapsible">
 _     _   _<h1><?php_echo $key['y'];?></h1>
    _     _ <?php
   ___    _ $last_year = $key['y'];
  _  _  }
    __ ?>
    __  <div data-role="collapsible">
  ___    _  <h1><?php echo $key['m'];?></h1>
 _        _ <div><?php echo_$key['nombre'];?></div>
    ___ </div>
        <?php_}?>
 _  </div>
_   <?php }?>
</div>

Here's the version that adds days_within months:
<?php
$count_month = $bdd -> query
(
 _  'SELECT YEAR(date_creation) as y, MONTH(date_creation) as m, DAY(date_creation) AS_d, COUNT(id) as nombre
    _FROM rdv
     WHERE_YEAR(date_creation) =