Forum Moderators: open

Message Too Old, No Replies

Conditional Query

Conditional Query

         

gckorn

8:31 pm on May 29, 2008 (gmt 0)

10+ Year Member



I am trying to update a mysql query to limit the data that is pulled so that it only pulls from 1 state (e.g., Maine) at a time. Current code is as follows. Anyone know how to modify this to limit the data, i.e., state='maine' ---

$cat = $_GET['cat'];
if ($ucat == "Others") {
$ucat = "Other Events";
}

$rssdays = getOption('rssdays');
$rsslimit = getOption('rsslimit');

$query = "select id, title, linkurl, city, state, postalcode, phone, format(longitude, 6) as longitude,
format(latitude, 6) as latitude, description, date_format(startdate, '%b %d') as startdate1,
date_format(enddate, '%b %d') as enddate1, photourl1, displayin, startdate, enddatefrom maine_festivals
where ((datediff(startdate, current_date) > 0 and datediff(startdate,current_date) < $rssdays)
or (datediff(startdate, current_date) <= 0 and datediff(enddate, current_date) between 0 and 180))
and category = '$cat'order by startdate, enddate ";
//and displayin in ('r', 'b')
if($rsslimit > 0)
$query .= " limit $rsslimit ";
else
$query .= " limit 45 ";

$result = mysql_query($query);
$currMonth = date("F");
$currMonth = strtolower($currMonth);
$linkcat = urlencode(strtolower($cat));

gck

dreamcatcher

7:34 am on May 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



and category = '$cat' and state = 'maine' order by startdate, enddate

dc

gckorn

11:29 am on May 30, 2008 (gmt 0)

10+ Year Member



That worked! Thanks Dreamcatcher.

gck