Jump to content

How to get PHP/MYSQL to search within a range


tgmd

Recommended Posts

I have a database that contains the columns keywords, month, day, year

 

I need to search the keyword column, but here's the part I can't figure out,  I need to search it within a date range.

 

So I can search from 12/2/06 - 11/4/07 etc.

 

I think I got most of it done, but I'm stuck on one issue. How do I get mysql/php to search a range?

 

What I got so far:

A script that can get the difference between the dates correctly (in my example it comes out as, 11, 2, 1)

A basic search, where I can search by keywords and certain dates, but I cannot search by keywords in a range of dates.

 

Any help would be greatly appreciated guys.

Im not sure why would you want to create 3 columns for day, month and year when you have so many formats available including timestamp, date and you can also save unix_timestamp in integer format..

 

You can easily query the database for date using all these 3 formats.

Nah I can't this is part of a bigger project.

 

The days month and year must be separate (I don't want to write a regular expression to separate them)

 

But perhaps I could just put a time stamp in, in addition to the day, month, year.

 

That would make more sense. How do I search within a range though?

Nah I can't this is part of a bigger project.

 

The days month and year must be separate (I don't want to write a regular expression to separate them)

 

But perhaps I could just put a time stamp in, in addition to the day, month, year.

 

That would make more sense. How do I search within a range though?

 

You can seperate them by:

list($year, $month, $day) = explode('-', $row['date']);

;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.