Hello to all. I have a problem I can not solve.
I have a table where there is a date field (datatime) where it goes automatically inserted the date and time of insertion. So 2013-09-02 12:00:00 AM. For me, this field is essential. Now I wanted to make a search form interval between two dates (for now because after I also need the time).
I tried this query PHP code:

$ query = "SELECT * FROM clients WHERE 1 = 1";
     w_data $ = "";
     if ($ data! = "") {$ w_data = 'between'% ". $ data."% 'AND'% ". $ data."% '";}
     w_intervento $ = "";
     if ($ action! = "") {$ w_intervento = "AND action LIKE '%". $ intervention. "%'";}
     w_cognome $ = "";
     if ($ name! = "") {$ w_cognome = "AND name LIKE '%". $ name. "%'";}
     w_nome $ = "";
     if ($ name! = "") {$ w_nome = "AND name LIKE '%". $ name. "%'";}
     $ query. = $ w_intervento. $ w_cognome. $ w_nome. $ w_data. "ORDER BY id";

I did not return any results, and if I go on phpmysql inserting PHP code:

SELECT *
FROM `clients`
WHERE date
BETWEEN '2013-07-05% '
AND '2013-07-12% '
LIMIT 0, 30

working properly. How can I do?
In the search form so I put PHP code:

<input id="data" name="data" type="date">
      <input id="data" name="data" type="date">

has been included twice because I need "from" "to" practically.

thanks

Member Avatar for LastMitch

I have a problem I can not solve.

@lelemkop

I am a bit curious how you manage not getting any errors? There should be errors popping left and right. It would be nice if you can explain a little how you figure your your issue.

my problem was to search by date . Basically, when I was looking for events by date research gave no results. I solved the problem by inserting if ($ data! = "") {$ w_data = ' and data between '% ". $ data."% 'AND'% ". $ data."% '";} ecc ecc

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.