Solved

choose between dates

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 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

16 Experts available now in Live!

Get 1:1 Help Now