Database access failed: INSERT INTO statistics VALUES(NULL, 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)', '10.45.144.228', '', '/last_article.php?pid=22', 'Browser Unknown', 'Unknown OS', now())
Column count doesn't match value count at row 1

Last Article

We use cookies to improve our services and products. Please refer to our terms and privacy policy for more information. We DO NOT use 3rd Party cookies or tracking software. And We DO NOT sell data to 3rd party vendors. We value your privacy.



AboutBlogContactGallery


Day Logic - Multi-Array

written by: Michael Paul MacKillip
Reader Mode 
|



posted on: Sep 26, 2019



This is the logic sequence I used to return two 'day' arrays, that return values for M-S for tables looking back over the last week, with results populating from left to right and right to left. Results display as a single letter value M T W T F S S.

It is based on a number line going infinitely in opposite directions.

-9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9

9 8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9

The initial server request returns a numeric value which is translated into a letter value for the given day. This logic sequence returns two date arrays. One array displaying results right to left for the last week. And one array displaying left to right for the last week.

M T W T F S S

S S F T W T M


This is a small snippit of the basic formula



$day = date("w");
$t = "";

if (preg_match("/0/", $day)) {
$t = "S";
} else if (preg_match("/1/", $day)) {
$t = "M";
} else if (preg_match("/2/", $day)) {
$t = "T";
} else if (preg_match("/3/", $day)) {
$t = "W";
} else if (preg_match("/4/", $day)) {
$t = "Th";
} else if (preg_match("/5/", $day)) {
$t = "F";
} else if (preg_match("/6/", $day)) {
$t = "Sa";
} else if (preg_match("/7/", $day)) {
$t = "S";
}

echo "Today is ";
echo $t;




Below is an image of the example I was able to accomplish using php to help populate dynamic graphs using chart.js for the frontend display. With both charts looking over data for the last week for with displays, from left to right and right to left.


Logic Graph Picture

Comments: (0)









Need IT/Tech?
we can help