In the mySQL table there is table_id, reception_date, patient_id, uid_document. Every doctor can take several patients every day. For example 2017.06.23 - 2 receptions, 2017.06.24 - 1 reception and so on.

On the page of the doctor you need to display it in the HTML table. Looking at this so that the accountant immediately knew how many receptions for each date at the doctor. In the form of date-number of receptions and all. What is the request to "write" for this? I'm doing this now

<?php $result100 = mysqli_query($con,"SELECT num, prdate, COUNT(*) FROM priem WHERE doctor_uid=$uidforfaq GROUP BY num, prdate ;") or die("<p>Не удается выбрать запись из базы данных</p>". mysqli_error($con)); $rowcount2 = mysqli_num_rows($result100); ?> 

Here is the num id of the table, the prdate date of admission But he gives me all the receptions for all the time. And it is necessary that it was DATE-NUMBER of RECEPTIONS .... Maybe for a date to make a separate request. Then I do not know how to explain mySQL so that it sorted by this date. In short, I can not figure anything out. Tell me please !

  • SELECT count(num) as cnt, prdate FROM priem WHERE doctor_uid=$uidforfaq GROUP BY prdate ; - Alexey Shimansky
  • Do you have the exact prdate field - is it a date field, not a date-time field? check using GROUP BY DATE(prdate), ... - Akina
  • yes this is a date field. - Alex Stassov

2 answers 2

 SELECT doctor_uid, prdate, COUNT(*) FROM priem WHERE doctor_uid=$uidforfaq GROUP BY prdate 

And so on for every doctor. You will still show the tables separately for convenience - you will not need to divide the sample into parts.

    I hope this helps you.

     SELECT COUNT(`num`) AS `num`, DATE_FORMAT(`prdate`, '%Y-%m-%d') AS `prdate` FROM priem WHERE doctor_uid = `11` GROUP BY DATE_FORMAT(`prdate`, '%Y-%m-%d') 
    • Alexey Shimansky, sanmai, Shnur Thank you for the answers dear friends! But it shows the number of receptions 1. And in fact, the number of receptions 2. He sorts by my date. As for ONE day two receptions. Maybe I incorrectly bring to the page. I completely forgot to say that I am outputting <? Php echo $ rowcount2; ?> - Alex Stassov