Master please come in, ask a PHP data processing problems
Use PHP and MySQL to achieve a patient appointment statistics function:
When the page is loaded by default, all incoming data is displayed, and you can search by entering the date of the consultation:
Now to implement this function to how to implement, the following code is I now implement the part, may not be written correctly, please help to achieve this function.
MySQL data table structure CREATE table ' Yuyue ' (
' id ' int (one) not NULL auto_increment, ' ID autonumber
' Fangshi ' varchar default NULL, ' reservation method: divided into network and telephone
' yydate ' varchar (+) default NULL, ' appointment date
' djdate ' varchar (+) default NULL, ' Date of registration '
' Dzhen ' int (one) default ' 0 ', ' whether to: 0 also, 1 is
' dzdate ' varchar (+) default NULL, ' Date of appointment
PRIMARY KEY (' id ')
) Engine=myisam auto_increment=2333 DEFAULT Charset=utf8;
function.inc.php
PHP Code
= ' $date 1 ' and ' dzdate ' <= ' $date 2 ' "; } if (!empty ($date 1) && empty ($date 2)) { $sql = $sql. "and ' dzdate ' = ' $date 1 '"; } if (Empty ($date 1) &&!empty ($date 2)) { $sql = $sql. "And ' dzdate ' <= ' $date 2 '"; } return $sql; }
PHP Code
(to the Consultation person chart) (Book a Patient chart) (Registered patient chart)
date of the appointment |
Week |
Number of appointments |
number of visits to the clinic |
the number of missed appointments |
GetCount ($STR); $sql = "SELECT count (*) as ' num ', ' yydate ', ' dzdate ' from ' Yuyue ' where ' dzhen ' = 1"; $sql = "SELECT count (*) as ' num ', ' yydate ', ' dzdate ' from ' Yuyue ' where ' dzhen ' = 1"; $sql =!empty ($date 1)? $sql. Dzdate ($tt, $date 1, $date 2): $sql; $sql = $sql. " GROUP BY ' dzdate ' ORDER by ' dzdate ' desc; $sql 2 = "SELECT COUNT (*) as ' num ', ' yydate ', ' dzdate ' from ' Yuyue ' where ' dzhen ' =0 or ' dzhen ' = 1"; $sql 2 =!empty ($date 1)? $sql. Yydate ($tt, $date 1, $date 2): $sql; $sql 2 = $sql 2. " GROUP BY ' dzdate ' ORDER by ' dzdate ' desc; $result = $db->query ($sql); $result 2 = $db->query ($sql 2); while ($rs = $db->fetch_array ($result)) {?>
|
|
|
|
|
Total |
|
|
|