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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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']);

;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.