Jump to content

[SOLVED] Searching all records between two dates


xeidor

Recommended Posts

I am trying to create a search function that will allow me to enter two dates and have the result output all the information between those two dates. As I have it set up right now i can enter the start date and the end date and it will give me the information for those two dates but nothing in between. Heres what i have so far for code, I know I'm missing the code that makes it select all the stuff in between the dates but I'm not sure where to start.

 

$date_Recordset1 = "1";

if (isset($_GET['date'])) {

  $date_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['date'] : addslashes($_GET['date']);

}

$date2_Recordset1 = "1";

if (isset($_GET['date2'])) {

  $date2_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['date2'] : addslashes($_GET['date2']);

}

 

$query_Recordset1 = sprintf("SELECT * FROM info WHERE date = '%s' OR date = '%s'  ORDER BY `date` ASC", $date_Recordset1,$date2_Recordset1);

 

Any help would be appreciated,

Thanks

Link to comment
Share on other sites

Edit:

 

Got it to work, changed it to:

 

$query_Recordset1 = sprintf("SELECT * FROM info WHERE date between '%s' and '%s' ORDER BY `date` ASC", $date_Recordset1,$date2_Recordset1);

 

Thanks for the help jvrothjr

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.