I would like to query regulation which it's date reminder is >= today and it's date ended is >=today.

So I came with this query:

$query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'"

It works on postgerSQL but not on mysql :( I dont why It couldn't work on mySQL

Please help me to revise this query

echo $query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'";

copy the output of echo statement and execute in mysql check whether query gives correct result or not.
if you got correct output then write..

$sql=mysql_query($query);

I have echo the query it seems well but it doesnt return a value. I dont know why it doesnt work on MySql

post you code and table structure + value related to this ..

table structure is:
t_master_reg
--------------------------------------------------------
|field | type data |
--------------------------------------------------------
id_reg |VARCHAR
no_reg |VARCHAR
reg_subject | VARCHAR
dt_reg_stated | DATE
dt_reg_end | DATE
dt_reg_reminder | DATE

values ('1','regulation no 546','regulation subject','2009-05-05','2009-07-31','2009-06-31')

Here is my code

$query = 'SELECT * FROM t_master_reg dt_reg_reminder >= '$today' AND dt_reg_end >='$today' ';

if I executed the query it will return an empty result. What should I do.Please help me..

What is $today equal to?

What is $today equal to?

$today= date("Y-m-d");
the result is $today=2009-05-21

I would like to query regulation which it's date reminder is >= today and it's date ended is >=today.

So I came with this query:

$query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'"

It works on postgerSQL but not on mysql :( I dont why It couldn't work on mySQL

Please help me to revise this query

Hi u can refer the following link, It might help u to solve ur problem.
http://www.w3schools.com/php/php_ref_date.asp

I would like to query regulation which it's date reminder is >= today and it's date ended is >=today.

So I came with this query:

$query="select * from t_regulation where dt_reminder >= '$today' && dt_ended ='$today'"

It works on postgerSQL but not on mysql :( I dont why It couldn't work on mySQL

Please help me to revise this query

Re: please try this, and - letters is not using - using only simbol (&&)

What exactly do you want it to do?

Did you print the query and execute it in mysql console or phpmyadmin ? Does that return any records ?
If Yes, then it should work in this case too.
If No, then you don't have any records in the table.

Echo the query and post it here.

@ koolhq : I want to display data when it's reminder date is today and always keep diplaying it until it's end of date.

@nav33n: i have try execute in the query on phpmyadmin and it doesnt return any query

$query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'"

Which query are you exactly using ? Because, earlier you had posted

//wrong query, quotes are all mixed up
$query = 'SELECT * FROM t_master_reg dt_reg_reminder >= '$today' AND dt_reg_end >='$today' ';

Now,

$query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'"

The above query will only work if there is an entry in the table where dt_reminder >= '2009-05-22' and dt_ended='2009-05-22'.
Do you have a record ?
If you execute the query in phpmyadmin and if it doesn't return any record, then obviously there are no records (or) you are passing the wrong query.
Echo the query and show us what it prints (not the query with variables in it).

Which query are you exactly using ? Because, earlier you had posted

//wrong query, quotes are all mixed up
$query = 'SELECT * FROM t_master_reg dt_reg_reminder >= '$today' AND dt_reg_end >='$today' ';

Now,

$query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'"

The above query will only work if there is an entry in the table where dt_reminder >= '2009-05-22' and dt_ended='2009-05-22'.
Do you have a record ?
If you execute the query in phpmyadmin and if it doesn't return any record, then obviously there are no records (or) you are passing the wrong query.
Echo the query and show us what it prints (not the query with variables in it).

I change my query to :

$query="select * from t_regulation where dt_reminder <= '$today' and dt_ended> ='$today'"

and it's work .. thank you for yourpost. I really appreciate it!! Finnally I found the suitable one. Thank a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.