List Info

Thread: Create a search by date RANGE




Create a search by date RANGE
country flaguser name
United States
2008-03-30 14:34:16

Hello All,

I need you all again. I have a event page that search by date but I
want visitors/users to be able to search by date range. I've searched
Google for this but I must be wording it wrong because I'm not getting
the solution.

Here's the page I'm referring to -
http://mybusinesscircle.startlogic.com/events.php

I also need a code to drop events once the date has passed.

Thanks,

Tisha

__._,_.___
.

__,_._,___
Re: Create a search by date RANGE
country flaguser name
Australia
2008-03-30 17:23:06

----- Original Message -----
From: "fremaje31"

Hello All,

I need you all again. I have a event page that search by date but I
want visitors/users to be able to search by date range. I've searched
Google for this but I must be wording it wrong because I'm not getting
the solution.

Here's the page I'm referring to -
http://mybusinesscircle.startlogic.com/events.php

I also need a code to drop events once the date has passed.

Thanks,

Tisha

------------------------------------

It's a bit hard without seeing the code!

An example, not the best way as I don't what code you already have.

function testdate($string)
{
$result = substr($string$, 6, 4);
$result .= substr($string, 0, 2);
$result .= substr($string, 3, 2);
return $result;
}

function inrange($current, $start, $end)
{
$current = testdate($current);
$start = testdate($start);
$end = testdate$($end);
if($cuurent < $start) {return FALSE;}
if($current > $end} (return FALSE;}
return TRUE;
}

$startdate = '01/01/2008';
$enddate = '12/31/2008';

foreach($dataitem as $thisdataitem)
{
$thisdate = $thisdataitem['date'];
if(inrange($thisdate, $startdate, $enddate))
{
// echo HTML for this item
}
$currentdate = date(//please insert date format string for MM/DD/YYYY);
if(testdate($thisdate) < testdate($currentdate))
{
// delete this data item
}
}

Rob.

__._,_.___
.

__,_._,___
Re: Create a search by date RANGE
country flaguser name
United States
2008-03-30 23:00:46

--- fremaje31 < yevayig%40gmail.com">yevayiggmail.com> wrote:

> I need you all again. I have a event page that search by date but I
> want visitors/users to be able to search by date range. I've searched
> Google for this but I must be wording it wrong because I'm not getting
> the solution.
>
> Here's the page I'm referring to -
> http://mybusinesscircle.startlogic.com/events.php
>
> I also need a code to drop events once the date has passed.
>
> Thanks,
>
> Tisha

You don't say but I guess you are using MySQL? If so, you will want to know
about the BETWEEN syntax:

SELECT * FROM tablename WHERE datefield BETWEEN startdate AND enddate;

The values of startdate would generally be in the YYYY-MM-DD format unless the
datefield is a date-time when you'd make the appropriate adjustment. The
BETWEEN clause can be used for other data types as well, of course.

With this you can do some interesting things from your PHP forms. Typically,
each time a PHP/web form is submitted, you will take the input values, validate
them, and use them for a SELECT...BETWEEN query.

Now, perhaps you want to adjust the display without a page reload. This is
more of a topic for a Javascript or AJAX list. However, you can put your
values from MySQL into a Javascript array (or a bunch of HTML <div>; tags with
unique id values) and then use Javascript to affect the display of these
elements.

As always, the more detail you provide, the more specific and appropriate our
answers can be. However, if it is client-side coding, make use of some of the
groups where that is their specialty. We are mostly PHP/MySQL here with some
other SQL databases making cameo appearances.

James

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )