473,378 Members | 1,364 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

comparison condition in php + mysql

how can we count the total of row between two value that include both fields of value ($input1<=startDate>=$input2 not $input1<startDate>$input2!!)

here is my code,is that true?

$query = "SELECT * FROM excomplaint WHERE startDate BETWEEN '$input1' AND '$input2'";
Feb 28 '07 #1
8 2690
ronverdonk
4,258 Expert 4TB
That query should give the correct results.

Ronald :cool:
Feb 28 '07 #2
so,how to differentiate between both query..is that true if both condition using the same query?
Mar 1 '07 #3
ronverdonk
4,258 Expert 4TB
I am not quite sure what you asking for. Hope this is it: the select for the second condition
Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT * FROM excomplaint 
  2.    WHERE startDate > '$input1' 
  3.      AND startDate < '$input2'";
Ronald :cool:
Mar 2 '07 #4
I am not quite sure what you asking for. Hope this is it: the select for the second condition
Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT * FROM excomplaint 
  2.    WHERE startDate > '$input1' 
  3.      AND startDate < '$input2'";
Ronald :cool:

i get the true output..thanks..
but,can or not php support when i have declare for startDate datatype is varchar because it include '/'?
Mar 6 '07 #5
ronverdonk
4,258 Expert 4TB
A MySQL date field with data type DATE always has format 'YYYY-MM-DD'. When you are using another format you will most likely run into problems when trying to perform MySQL date calculations.

So when you are using a MySQL date field of which the stored value must be e.g. 'DD/MM/YYYY' you cannot store that into a MySQL DATE type field, but e.g. in a MySQL char type field. Then you cannot perform date calculations.

I would suggest that you always store a date in MySQL in the standard DATE format (YYYY-MM-DD) and convert any external fields into that format when storing and reformat back to your own format after retrieving and displaying.

Ronald :cool:
Mar 6 '07 #6
A MySQL date field with data type DATE always has format 'YYYY-MM-DD'. When you are using another format you will most likely run into problems when trying to perform MySQL date calculations.

So when you are using a MySQL date field of which the stored value must be e.g. 'DD/MM/YYYY' you cannot store that into a MySQL DATE type field, but e.g. in a MySQL char type field. Then you cannot perform date calculations.

I would suggest that you always store a date in MySQL in the standard DATE format (YYYY-MM-DD) and convert any external fields into that format when storing and reformat back to your own format after retrieving and displaying.

Ronald :cool:
But i want the output of startDate is '1/2/2007'..if i use DATE datatype, the output is '2007/2/1'.so how can i solve this problem?
Mar 7 '07 #7
gauravgmbhr
107 100+
But i want the output of startDate is '1/2/2007'..if i use DATE datatype, the output is '2007/2/1'.so how can i solve this problem?
I am not sure bout what u r asking

i think when u r passing two inputs to the query and having a between clause in ur querythen ur query will get the job done

if u wanna count the rows try mysql_num_rows($result_handle);
Mar 7 '07 #8
ronverdonk
4,258 Expert 4TB
I am not sure bout what u r asking
i think when u r passing two inputs to the query and having a between clause in ur query
then ur query will get the job done
if u wanna count the rows try mysql_num_rows($result_handle);
gauravgmbhr: why don't you read the entire thread before replying? This is not what was asked, doesn't come close.

Ronald :cool:
Mar 9 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: democratix | last post by:
Hi, I've only got a couple years experience developing for Access but have recently been experimenting with HTML/javascript for gui and client-side scripting, mysql for database and php for...
5
by: news | last post by:
I'm trying out the Zend Development Environment 4, and for the most part I like it, except for two things. It seems to think certain lines that are perfectly valid are bugs. Like this: while...
7
by: Craig Keightley | last post by:
is it possible to compare acomma separated list aginst another eg comma list 1 => 1,2,3,4,5 comma list 2 => 3,5 can you check that 3 is in both, and 5 is in both, therfore they match??? the...
2
by: Branko | last post by:
Hello all, I have 2 columns and I search rows with two conditions. SELECT * FROM table WHERE A = '$a' AND B = '$b' How can I make mysql search columns with A condition first and after that...
0
by: JT | last post by:
Hi, I'm sure this isn't a hard one, can someone help? I'm adding a new record to a MySQL database every x seconds. I need to be able to inspect the content of a certain field in this incoming...
133
by: jonathan | last post by:
hey all, I realize that this question might pop up from time to time, but I haven't seen it a while and things might of changed, so - Right now (July 2004) how does mysql stand up in...
2
by: toocool | last post by:
Hi, I'm having a problem with one query. My database has the following fields: id(int), time(int), and groupfield(enum - 5 possibilities). I want to select all the rows where the time is between...
1
by: bjjnova | last post by:
I have the following string comparison that is throwing an error I cannot find ( I will include my attempts to trace the error) In the line following the asterisks, written as I have below, a...
3
by: hazahafiz | last post by:
hye guest.. anybody can help me how to make sql query for comparison condition. in case,i want to generate report between range two date for example 1/2/2007 until 20/2/2007?
1
by: damezumari | last post by:
How do I get the total without a condition and the total with the condition at the same time? This is my mysql table: id datetimeconfirmed customerid amount 1 ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.