Advertisement

08.29.2008 at 12:08PM PDT, ID: 23689825
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

how to get the todays date and the date 60 days before todays date in php and pass it as a query to mysql?

Asked by blue-lotus in PHP Scripting Language, Apache Web Server, MySQL Server

Tags:

I need to get data for the last 60 days using mysql and php. using those data's i need to create a graph.

i have a form in the main page which pass the date to the calling page and use that to do the query for date(It works). What does not work is, to be able to query for the last 60 days for default(when some one get to the landing page it should do the query for the last 60 days).

Everything was working before until I tried to query against the date. i get the error "The image http://localhost/mantis/analytics_byseverity_status.php?status=All&start_day=&start_month=&start_year=&end_day=&end_month=&end_year= cannot be displayed, because it contains errors."

I got the today's date and date before 60 days working, but when i try to pass it as a parameter in the function, it does not work. I think it has to do with the making Global variable.

Please help me.

I have attached the code snippet

Start Free Trial
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:
<?php			
	$t_status = $_GET['status'];
	
	$start_date  = 0;
	$end_date = 0;
	
	$start_day = $_GET['start_day'];
	$start_month = $_GET['start_month'];
	$start_year = $_GET['start_year'];
		
	$end_day = $_GET['end_day'];
	$end_month = $_GET['end_month'];
	$end_year = $_GET['end_year'];
	
	if($start_day != null){
		global $start_date, $end_date, $start_day, $start_month, $start_year, $end_day, $end_month, $end_year;
		$start_date = "$start_year-$start_month-$start_day";
		$end_date = "$end_year-$end_month-$end_day";
	}
	else
	{
		global $start_date, $end_date, $start_day, $start_month, $start_year, $end_day, $end_month, $end_year;
		$today = getdate();
		$start_day = $today['mday'];
		$start_month = $today['mon'];
		$start_year = $today['year'];
		$unix = $today['0'];
 
		$diff = $unix - (60*60*24*2*30); #difference of 60 days
		$date = getDate($diff);
 
		$end_day = $date['mday'];
		$end_month = $date['mon'];
		$end_year = $date['year'];
			
		$start_date = "$start_year-$start_month-$start_day";
		$end_date = "$end_year-$end_month-$end_day";
		
	
	}
		echo "start_date " . $start_date ."<br>";
		echo "end_date " . $end_date ."<br>";
		
		$f_width = gpc_get_int( $t_graph_width, 300 );
 
		$f_token = gpc_get_int( $t_token, 0 );
		if ( 0 == $f_token ) {
			$t_metrics = chart_severity_status( lang_get( 'severity_enum_string' ), 'severity', $t_status, $start_date, $end_date);
		} else {
			$t_metrics = graph_total_metrics( unserialize( token_get_value( $f_token ) ) );
		}
		analytics_pie( $t_metrics, lang_get( 'by_severity_mix' ), $f_width, $f_width, $t_status,$start_year,$start_month,$start_day,$end_year,$end_month,$end_day);
	
	
?>
 
Loading Advertisement...
 
[+][-]08.29.2008 at 05:18PM PDT, ID: 22349995

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Apache Web Server, MySQL Server
Tags: php, mysql, sql
Sign Up Now!
Solution Provided By: Chakotay505
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.31.2008 at 10:29AM PDT, ID: 22355700

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.31.2008 at 11:04AM PDT, ID: 22355813

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.31.2008 at 11:53AM PDT, ID: 22355952

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628