Home  >  Article  >  Backend Development  >  How to implement dynamic histogram in PHP_PHP tutorial

How to implement dynamic histogram in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:59:081175browse

PHP dynamic histogram implementation method

This article mainly introduces the PHP dynamic histogram implementation method. It analyzes the techniques of PHP combined with HTML elements to implement dynamic histogram. It is very useful. Practical value, friends in need can refer to it

The example in this article describes the implementation method of dynamic histogram in PHP. Share it with everyone for your reference. The specific analysis is as follows:

1. Demand

Query the total number of data items and the number of approved items in the last month, and make a histogram

2. Implementation code:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

//Calculate today’s day of the previous month

function last_month_today($time){

$last_month_time = mktime(date("G", $time), date("i", $time),date("s", $time), date("n", $time), 0, date("Y",$time));

$last_month_t = date("t", $last_month_time);

if ($last_month_t < date("j", $time)) {

return date("Y-m-t H:i:s", $last_month_time);

}

return date(date("Y-m", $last_month_time) . "-d", $time);

}

?>

include dirname(dirname(dirname(__FILE__))).'/config.php';

$endDate = date('Y-m-d');

$date = strtotime($endDate);

$beginDate= last_month_today($date);

//Query the total number of data items in the last month

$sql = 'select count(*) from newpro where p_date>''.$beginDate.'' and p_date<''.$endDate.''';

//$sql = "select count(*) from newpro where p_date>'$beginDate' and p_date <'$endDate'";//This statement can also be used

$d = db()->query($sql)->fetch(PDO::FETCH_NUM);

//echo "Total number of data items:".$d[0];

//Query the number of data items that have passed the review

$sql2=$sql.' and is_pa_check_first=1 and is_pa_check_second=1 and is_pa_check_third=1';

$d2 = db()->query($sql2)->fetch(PDO::FETCH_NUM);

//echo "Number of data items passed the review:".$d2[0];

//Query the number of items that have passed the review

$sql3=$sql.' and is_pa_check_first=1';

$d3 = db()->query($sql3)->fetch(PDO::FETCH_NUM);

//Query the number of items that passed the second review

$sql4=$sql.' and is_pa_check_first=1 and is_pa_check_second=1';

$d4 = db()->query($sql4)->fetch(PDO::FETCH_NUM);

?>

 

总计

一审通过

二审通过

审核通过

3.效果图如下所示:

PHP动态柱状图实现方法   帮客之家

希望本文所述对大家的php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/976532.htmlTechArticlePHP动态柱状图实现方法 这篇文章主要介绍了PHP动态柱状图实现方法,实例分析了php结合HTML元素实现动态柱状图的技巧,非常具有实用价值,需...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn