Solved

choose between dates

Posted on 2011-03-06
2
236 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now