dynamic url search links

2 posts by 2 authors in: Forums > CMS Builder
Last Post: March 8, 2012   (RSS)

By markr - March 7, 2012

I was looking to create url search links based on the month of the event. Easy enough...

E.g. /listpage.php?event_month=4

But I didn't want 12 static links (one for each month) if my events only went out a few months.

Just wanted to share my query and loop with the forum:

$result = mysql_query("SELECT DISTINCT MONTH(event) AS `Month` FROM `cms_games` WHERE `event` > NOW() ORDER BY `event` ASC");

while($row = mysql_fetch_array($result)) {
$monthName = date("F", mktime(0, 0, 0, $row['Month']));
$monthNumber = date("m", mktime(0, 0, 0, $row['Month']));
echo "<a href ='listpage.php?event_month=".$monthNumber."'>".$monthName."</a>";
} // end while