gmdate("Y")) { echo "Sorry, you cannot view future brides."; return; } //if the year in the url is the current year but the month is greater than the current, don't show anything else if (($year == gmdate("Y")) && ($month > gmdate("n"))) { echo "Sorry, you cannot view future brides."; return; } $myDB = MyDatabase::initMyDB('laraines_boutique', 'bride_of_the_month'); $query = "SELECT * FROM $myDB->table WHERE year = '".$year."' AND month = '".$month."'"; //get the active bride specified by the url or the current year/month $activeBride = mysql_query($query) or die(mysql_error()); $rowNum = mysql_num_rows($activeBride); //a loop to find the last entered bride from the cms, if the current month doesn't have one while ($rowNum == 0) { //if the month is not less than 1 (which doesn't exist) //de-iterate the months and run the select again if (!($month < 1)) { $month--; $activeBride = mysql_query($query) or die(mysql_error()); $rowNum = mysql_num_rows($activeBride); } //if the month is less than 1 (which doesn't exist) //set the month to the highest possible (12) and de-iterate the year and run the select again else { $month = 12; $year--; $activeBride = mysql_query($query) or die(mysql_error()); $rowNum = mysql_num_rows($activeBride); } //if the year is 2011 or less, run the sorry (the cms didn't exist back then) if ($year <= 2011) { echo "Sorry, there are no brides of the month for that time range."; return; } } // Print out the contents of the entry while($row = mysql_fetch_array($activeBride)){ $images = $row['images']; $thumbs = $row['thumbs']; $images = explode(", ", $images); $thumbs = explode(", ", $thumbs); $desc = $row['description']; $desc = nl2br($desc); echo '
'; echo '
'; echo '
'; echo '

' . $row['name'] . '

'; echo '

' . $desc . '

'; echo ''; echo '
'; } $myDB->closeConnection(); } ?> :: La Raine's Bridal Boutique - Bride of the Month
Sign up below for our Newsletter!
For Email Newsletters you can trust