Solved

choose between dates

Posted on 2011-03-06
2
240 Views
Last Modified: 2012-05-11
How can I rewrite this function and choose a result that is  in between certain dates for qt1 earnings etc..

my code is below. Thanks Experts!!.


function test($catagory, $date)
{

echo '<table border=1>';

include ($_SERVER['DOCUMENT_ROOT'] . '/onlineoffice/config/config.php');

mysql_pconnect($host, $user, $pass) or die ('Unable To Connect To Database!');

mysql_select_db('finanical_schema') or die ('Unable To Select Database!');

$query = "SELECT id, name, account_id, SUM(IF( b_accounts.Banking.type ='Withdrawl', -amount, amount)) 
		FROM finanical_schema.shema_names, b_accounts.Banking
		WHERE finanical_schema.shema_names.type ='$catagory' AND account_id = id GROUP BY id";

$result = mysql_query($query) or die ('Error in Selection query: $query. ' . mysql_error());

	while ($display = mysql_fetch_array($result, MYSQL_NUM))
		{
		echo '<tr><td>' . $display[1] . '</td><td>' . $display[3] . '</td></tr>';

		}


mysql_close();



}

Open in new window

0
Comment
Question by:Easyrider43
2 Comments
 
LVL 1

Expert Comment

by:lalitgada
ID: 35053425
0
 
LVL 22

Accepted Solution

by:
Om Prakash earned 500 total points
ID: 35053465
assuming $start_date and $end_date is passed
$query = "SELECT id, name, account_id, SUM(IF( b_accounts.Banking.type ='Withdrawl', -amount, amount)) 
		FROM finanical_schema.shema_names, b_accounts.Banking
		WHERE finanical_schema.shema_names.type ='$catagory' AND account_id = id 
		and date_field between '$start_date' and '$end_date
		GROUP BY id";

Open in new window

0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question