Solved

choose between dates

Posted on 2011-03-06
2
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
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 count occurrences of each item in an array.

688 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