=$ashMonday && $now <=$pentecost) { //Festival season. Look up by what week of Festival time we're in. // Season IDs: // 1: Lent // 2: Holy Week // 3: Easter Season // 4: Advent (non-movable); // 5: Christmas (non-movable); // 6: Epiphany (non-movable); // 7: Pentecost // 8: Ascension if ($now>=$ascension && $now<=$ascension+$oneDay) { //Ok, so it's Ascension Day... $sql1 = "SELECT * FROM tbl_daily_lectionary WHERE season = '8' LIMIT 1"; $description = "Ascension Day"; } elseif ($now>=$pentecost && $now<=$pentecost+$oneDay) { //Ok, so it's Pentecost Day... $sql1 = "SELECT * FROM tbl_daily_lectionary WHERE season = '7' AND week='14' AND weekday='$day'"; $description = "Pentecost"; } elseif ($now>=$ashWednesday && $now<$easter) { //Lententide $difference=$now-($ashWednesday-$oneDay*3); //Gotta measure from Sunday before Ash Wednesday for the time to fit. $daysDifference=floor($difference/$oneDay); $week = floor($daysDifference/7); if ($week=='6') { //Holy Week if ($day=="Sunday") { $sql1 = "SELECT * FROM tbl_daily_lectionary WHERE season = '1' AND week='$week' AND weekday='$day'"; $description = "Palm Sunday"; } else { $sql1 = "SELECT * FROM tbl_daily_lectionary WHERE season = '2' AND week='$week' AND weekday='$day'"; if ($day=="Thursday") { $description = "Holy Thursday"; } elseif ($day=="Friday") { $description = "Good Friday"; } else { $description = $day." of Holy Week"; } } } else { $sql1 = "SELECT * FROM tbl_daily_lectionary WHERE season = '1' AND week='$week' AND weekday='$day'"; $description = $day." of the ".ordinal($week)." Week of Lent"; } } elseif ($now>=$easter && $now<$pentecost) { //Eastertide $difference=$now-$easter; $daysDifference=floor($difference/$oneDay); $week = floor($daysDifference/7)+7; //No clue why database has +7 on this stuff. $sql1 = "SELECT * FROM tbl_daily_lectionary WHERE season = '3' AND week='$week' AND weekday='$day'"; $description = $day." of the ".ordinal($week-6)." Week of Easter"; } elseif ($now>=$pentecost && $now<$holyTrinity) { //Week after and including Pentecost $sql1 = "SELECT * FROM tbl_daily_lectionary WHERE season = '7' AND weekday='$day'"; if ($day=="Sunday") { $description = "Pentecost Sunday"; } else { $description = $day." of the Week of Pentecost"; } } else { //Try today's date...? We should never get here. $today = date('n-j'); $exploded = explode("-", $today); $curmonth = $exploded[0]; $curday = $exploded[1]; //This will do the OT section. Query the DB, only pulling out today $sql1 = "SELECT * FROM tbl_daily_lectionary WHERE month = '$curmonth' AND day = '$curday'"; } } else { //Ordinary Time. Use some of Roy's original code here. //Figure out today's Month and Day $today = date('n-j'); $exploded = explode("-", $today); $curmonth = $exploded[0]; $curday = $exploded[1]; //This will do the OT section. Query the DB, only pulling out today $sql1 = "SELECT * FROM tbl_daily_lectionary WHERE month = '$curmonth' AND day = '$curday'"; } //Perform SQL query $res1 = mysqli_query($conn,$sql1); $cnt1 = my sqli_num_rows($res1); echo $cnt1; if($cnt1 > 0) { while($data1 = mysqli_fetch_array($res1)) { print_r($data1); $OT_reading = $data1['OT_reading']; $OT_alt_reading=$data1['OT_alt_reading']; $NT_reading=$data1['NT_reading']; $NT_alt_reading=$data1['NT_alt_reading']; $color=$data1['color_id']; } } //Once readings are set, display those puppies. echo '
'; if ($description!=null && $description!="") { echo '

' .date('l, F d, Y',$now).' ('.$description. ')

'; } else { echo '

' .date('l, F d, Y',$now).'

'; } //Grabbing parament color for that day. $sql2="SELECT * FROM tbl_colors WHERE id='$color' LIMIT 1"; $res2 = mysqli_query($conn,$sql2); $cnt2 = mysqli_num_rows($res2); if($cnt2 > 0) { while($data2 = mysqli_fetch_array($res2)) { if ($data2['color_number']=="#FFFFFF") { $hex=="#000000"; } else { $hex = $data2['color_number']; } echo "

Parament color: ".ucfirst($data2['color_name'])."

"; } } //Print OT reading and alternate, if any. echo ''.GetScriptureText($OT_reading,$biblesOrgKey,$BiblesOrgPass).''; if($OT_alt_reading != NULL) { echo '

Show Alternate Passage

'."\n"; echo ''."\n"; } echo '
'; //Same for NT reading and alternate, if any. echo ''.GetScriptureText($NT_reading,$biblesOrgKey,$BiblesOrgPass).''; if($NT_alt_reading != NULL) { echo '

Show Alternate Passage

'."\n"; echo ''."\n"; } // For movable dates....I'm not quite sure what this was supposed to do. It appears large pieces of early code are missing. Disabling the "else" here to prevent this from executing until we can think of what it was trying to do. //else { echo '
'; //Fetch and return Scripture from a scripture reference function GetScriptureText_deprecated($reference,$biblesOrgKey,$BiblesOrgPass) { $passage = rawurlencode($reference); $url1 = "https://bibles.org/v2/eng-NASB/passages.xml?q[]=".$passage; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERPWD, "$biblesOrgKey:$biblesOrgPass"); $p = xml_parser_create(); $response = xml_parse_into_struct($p,curl_exec($ch),$vals,$index); curl_close($ch); $result = "

".$reference."

".$vals[12]["value"]; return $result; } function GetScriptureText($reference) { $esvAPIkey="a102ad9eac1a3670aa8a367fcb670ce1240d0b7e"; $passage = rawurlencode($reference); $esvAPIkey="a102ad9eac1a3670aa8a367fcb670ce1240d0b7e"; $url = "https://api.esv.org/v3/passage/html/?q=".$passage."&include-css-link=true"; $headers = [ 'Accept: application/json', 'Authorization: Token '.$esvAPIkey ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER,$headers); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $passages=json_decode($response)->passages; return ($passages[0]); } //Month number to month function function GetMonthString($n) { $timestamp = mktime(0, 0, 0, $n, 1, 2005); return date("F", $timestamp); } //Thanks Stackoverflow! https://stackoverflow.com/questions/3109978/display-numbers-with-ordinal-suffix-in-php function ordinal($number) { $ends = array('th','st','nd','rd','th','th','th','th','th','th'); if ((($number % 100) >= 11) && (($number%100) <= 13)) return $number. 'th'; else return $number. $ends[$number % 10]; } ?>