【PHP×MySQL】ランキングナビを自作しました | 無能投資家の苦悩');mask-image:url('data:image/svg+xml;utf8,');mask-mode:alpha;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-position:center;mask-position:center;border-radius:0}}.wp-block-latest-comments__comment{font-size:15px;line-height:1.1;list-style:none;margin-bottom:1em}.has-avatars .wp-block-latest-comments__comment{min-height:36px;list-style:none}.has-avatars .wp-block-latest-comments__comment .wp-block-latest-comments__comment-excerpt,.has-avatars .wp-block-latest-comments__comment .wp-block-latest-comments__comment-meta{margin-left:52px}.has-dates .wp-block-latest-comments__comment,.has-excerpts .wp-block-latest-comments__comment{line-height:1.5}.wp-block-latest-comments__comment-excerpt p{font-size:14px;line-height:1.8;margin:5px 0 20px}.wp-block-latest-comments__comment-date{color:#8f98a1;display:block;font-size:12px}.wp-block-latest-comments .avatar,.wp-block-latest-comments__comment-avatar{border-radius:24px;display:block;float:left;height:40px;margin-right:12px;width:40px}.wp-block-latest-posts.alignleft{margin-right:2em}.wp-block-latest-posts.alignright{margin-left:2em}.wp-block-latest-posts.wp-block-latest-posts__list{list-style:none}.wp-block-latest-posts.wp-block-latest-posts__list li{clear:both}.wp-block-latest-posts.is-grid{display:flex;flex-wrap:wrap;padding:0}.wp-block-latest-posts.is-grid li{margin:0 16px 16px 0;width:100%}@media (min-width:600px){.wp-block-latest-posts.columns-2 li{width:calc(50% - 16px)}.wp-block-latest-posts.columns-3 li{width:calc(33.33333% - 16px)}.wp-block-latest-posts.columns-4 li{width:calc(25% - 16px)}.wp-block-latest-posts.columns-5 li{width:calc(20% - 16px)}.wp-block-latest-posts.columns-6 li{width:calc(16.66667% - 16px)}}.wp-block-latest-posts__post-date{display:block;color:#6c7781;font-size:13px}.wp-block-latest-posts__post-excerpt{margin-top:8px;margin-bottom:16px}.wp-block-latest-posts__featured-image img{height:auto;width:auto}.wp-block-latest-posts__featured-image.alignleft{margin-right:1em}.wp-block-latest-posts__featured-image.alignright{margin-left:1em}.wp-block-latest-posts__featured-image.aligncenter{margin-bottom:1em;text-align:center}.wp-block-media-text{direction:ltr;display:-ms-grid;display:grid;-ms-grid-columns:50% 1fr;grid-template-columns:50% 1fr;-ms-grid-rows:auto;grid-template-rows:auto}.wp-block-media-text.has-media-on-the-right{-ms-grid-columns:1fr 50%;grid-template-columns:1fr 50%}.wp-block-media-text.is-vertically-aligned-top .wp-block-media-text__content,.wp-block-media-text.is-vertically-aligned-top .wp-block-media-text__media{-ms-grid-row-align:start;align-self:start}.wp-block-media-text.is-vertically-aligned-center .wp-block-media-text__content,.wp-block-media-text.is-vertically-aligned-center .wp-block-media-text__media,.wp-block-media-text .wp-block-media-text__content,.wp-block-media-text .wp-block-media-text__media{-ms-grid-row-align:center;align-self:center}.wp-block-media-text.is-vertically-aligned-bottom .wp-block-media-text__content,.wp-block-media-text.is-vertically-aligned-bottom .wp-block-media-text__media{-ms-grid-row-align:end;align-self:end}.wp-block-media-text .wp-block-media-text__media{-ms-grid-column:1;grid-column:1;-ms-grid-row:1;grid-row:1;margin:0}.wp-block-media-text .wp-block-media-text__content{direction:ltr;-ms-grid-column:2;grid-column:2;-ms-grid-row:1;grid-row:1;padding:0 8%;word-break:break-word}.wp-block-media-text.has-media-on-the-right .wp-block-media-text__media{-ms-grid-column:2;grid-column:2;-ms-grid-row:1;grid-row:1}.wp-block-media-text.has-media-on-the-right .wp-block-media-text__content{-ms-grid-column:1;grid-column:1;-ms-grid-row:1;grid-row:1}.wp-block-media-text>figure>img,.wp-block-media-text>figure>video{max-width:unset;width:100%;vertical-align:middle}.wp-block-media-text.is-image-fill figure.wp-block-media-text__media{height:100%;min-height:250px;background-size:cover}.wp-block-media-text.is-image-fill figure.wp-block-media-text__media>img{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}@media (max-width:600px){.wp-block-media-text.is-stacked-on-mobile{-ms-grid-columns:100%!important;grid-template-columns:100%!important}.wp-block-media-text.is-stacked-on-mobile .wp-block-media-text__media{-ms-grid-column:1;grid-column:1;-ms-grid-row:1;grid-row:1}.wp-block-media-text.is-stacked-on-mobile.has-media-on-the-right .wp-block-media-text__media,.wp-block-media-text.is-stacked-on-mobile .wp-block-media-text__content{-ms-grid-column:1;grid-column:1;-ms-grid-row:2;grid-row:2}.wp-block-media-text.is-stacked-on-mobile.has-media-on-the-right .wp-block-media-text__content{-ms-grid-column:1;grid-column:1;-ms-grid-row:1;grid-row:1}}.wp-block-navigation>ul{display:block;list-style:none;margin:0;padding-left:0}@media (min-width:600px){.wp-block-navigation>ul{display:flex;flex-wrap:wrap}}.wp-block-navigation>ul ul{list-style:none;padding-left:0;margin-top:0;margin-left:0}.wp-block-navigation>ul ul li{margin:0}.wp-block-navigation>ul li{z-index:1}.wp-block-navigation>ul li:focus-within,.wp-block-navigation>ul li:hover{cursor:pointer;z-index:99999}.wp-block-navigation>ul li:focus-within>ul,.wp-block-navigation>ul li:hover>ul,.wp-block-navigation>ul li ul:focus,.wp-block-navigation>ul li ul:hover{visibility:visible;opacity:1;display:flex;flex-direction:column}.wp-block-navigation>ul>li ul{position:absolute;left:0;top:100%;min-width:200px;max-width:200px;opacity:0;transition:opacity .1s linear;visibility:hidden}.wp-block-navigation,.wp-block-navigation .block-editor-block-list__layout{display:flex;flex-wrap:wrap}.wp-block-navigation .block-editor-block-list__layout .block-editor-block-list__layout{width:200px}.wp-block-navigation .block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block{margin:0;width:auto}.wp-block-navigation,.wp-block-navigation>.wp-block-navigation__container{align-items:center;width:100%}.wp-block-navigation>.wp-block-navigation-link,.wp-block-navigation>.wp-block-navigation__container>.wp-block-navigation-link{display:flex;margin-top:0;margin-bottom:0}.wp-block-navigation .wp-block-navigation-link{position:relative;margin:0;min-height:56px;display:flex;line-height:1.4}.wp-block-navigation .wp-block-navigation-link .wp-block,.wp-block-navigation .wp-block-navigation-link .wp-block-navigation-link{min-height:auto;padding:0}.wp-block-navigation .wp-block-navigation-link .wp-block .wp-block-navigation-link{margin:0}.wp-block-navigation .wp-block-navigation-link>.block-editor-inner-blocks{display:none}.wp-block-navigation .wp-block-navigation-link.has-child>.wp-block-navigation__container,.wp-block-navigation .wp-block-navigation-link.is-editing.has-child>.block-editor-inner-blocks{display:flex;border:1px solid rgba(0,0,0,.15);position:absolute;z-index:1;top:100%;left:0}.wp-block-navigation .wp-block-navigation-link.has-child>.wp-block-navigation__container .block-editor-inner-blocks,.wp-block-navigation .wp-block-navigation-link.has-child>.wp-block-navigation__container .wp-block-navigation__container,.wp-block-navigation .wp-block-navigation-link.is-editing.has-child>.block-editor-inner-blocks .block-editor-inner-blocks,.wp-block-navigation .wp-block-navigation-link.is-editing.has-child>.block-editor-inner-blocks .wp-block-navigation__container{left:100%;top:-1px}.wp-block-navigation .wp-block-navigation-link .block-editor-inner-blocks,.wp-block-navigation .wp-block-navigation-link .wp-block-navigation__container{background-color:inherit;color:inherit}.wp-block-navigation .wp-block-navigation-link .wp-block-navigation-link__content{display:flex;align-items:center;width:max-content;padding:6px 16px}.wp-block-navigation .wp-block-navigation-link .wp-block-navigation-link:first-child:not(:only-child) .wp-block-navigation-link__content{padding-top:8px}.wp-block-navigation .wp-block-navigation-link .wp-block-navigation-link:last-child .wp-block-navigation-link__content{padding-bottom:8px}.wp-block-navigation .wp-block-navigation-link.has-child .wp-block-navigation-link__content{min-width:100%;padding-right:32px;position:relative}.wp-block-navigation .wp-block-navigation-link .wp-block-navigation-link__submenu-icon{position:absolute;right:16px}.wp-block-navigation .wp-block-navigation-link .wp-block-navigation-link__submenu-icon svg{fill:currentColor}.wp-block-navigation .wp-block-navigation-link .wp-block-navigation-link svg{transform:rotate(0)}.wp-block-navigation .wp-block-navigation-link.has-text-color .wp-block-navigation-link__content{color:inherit}.wp-block-navigation.is-style-light .wp-block-navigation-link:not(.has-text-color)>.block-editor-inner-blocks,.wp-block-navigation.is-style-light .wp-block-navigation-link:not(.has-text-color)>.wp-block-navigation__container,.wp-block-navigation .wp-block-navigation-link:not(.has-text-color)>.block-editor-inner-blocks,.wp-block-navigation .wp-block-navigation-link:not(.has-text-color)>.wp-block-navigation__container{color:#111}.wp-block-navigation.is-style-light .wp-block-navigation-link:not(.has-background)>.block-editor-inner-blocks,.wp-block-navigation.is-style-light .wp-block-navigation-link:not(.has-background)>.wp-block-navigation__container,.wp-block-navigation .wp-block-navigation-link:not(.has-background)>.block-editor-inner-blocks,.wp-block-navigation .wp-block-navigation-link:not(.has-background)>.wp-block-navigation__container{background-color:#fff}.wp-block-navigation.is-style-dark .wp-block-navigation-link:not(.has-text-color)>.block-editor-inner-blocks,.wp-block-navigation.is-style-dark .wp-block-navigation-link:not(.has-text-color)>.wp-block-navigation__container{color:#fff}.wp-block-navigation.is-style-dark .wp-block-navigation-link:not(.has-background)>.block-editor-inner-blocks,.wp-block-navigation.is-style-dark .wp-block-navigation-link:not(.has-background)>.wp-block-navigation__container{background-color:#333}.wp-block-navigation .wp-block-navigation-link.has-child>.wp-block-navigation__container{display:flex;flex-direction:column;padding:0}.wp-block-navigation>ul>li>a{display:flex;align-items:center}.wp-block-navigation>ul>li:first-of-type>a{padding-left:0}.wp-block-navigation>ul>li:last-of-type>a{padding-right:0}.wp-block-navigation.items-justified-left>ul{justify-content:flex-start}.wp-block-navigation.items-justified-center>ul{justify-content:center}.wp-block-navigation.items-justified-right>ul{justify-content:flex-end}.is-small-text{font-size:14px}.is-regular-text{font-size:16px}.is-large-text{font-size:36px}.is-larger-text{font-size:48px}.has-drop-cap:not(:focus):first-letter{float:left;font-size:8.4em;line-height:.68;font-weight:100;margin:.05em .1em 0 0;text-transform:uppercase;font-style:normal}p.has-background{padding:20px 30px}p.has-text-color a{color:inherit}.wp-block-pullquote{padding:3em 0;margin-left:0;margin-right:0;text-align:center}.wp-block-pullquote.alignleft,.wp-block-pullquote.alignright{max-width:290px}.wp-block-pullquote.alignleft p,.wp-block-pullquote.alignright p{font-size:20px}.wp-block-pullquote p{font-size:28px;line-height:1.6}.wp-block-pullquote cite,.wp-block-pullquote footer{position:relative}.wp-block-pullquote .has-text-color a{color:inherit}.wp-block-pullquote:not(.is-style-solid-color){background:0 0}.wp-block-pullquote.is-style-solid-color{border:0}.wp-block-pullquote.is-style-solid-color blockquote{margin-left:auto;margin-right:auto;text-align:left;max-width:60%}.wp-block-pullquote.is-style-solid-color blockquote p{margin-top:0;margin-bottom:0;font-size:32px}.wp-block-pullquote.is-style-solid-color blockquote cite{text-transform:none;font-style:normal}.wp-block-pullquote cite{color:inherit}.wp-block-quote.is-large,.wp-block-quote.is-style-large{margin:0 0 16px;padding:0 1em}.wp-block-quote.is-large p,.wp-block-quote.is-style-large p{font-size:24px;font-style:italic;line-height:1.6}.wp-block-quote.is-large cite,.wp-block-quote.is-large footer,.wp-block-quote.is-style-large cite,.wp-block-quote.is-style-large footer{font-size:18px;text-align:right}.wp-block-rss.alignleft{margin-right:2em}.wp-block-rss.alignright{margin-left:2em}.wp-block-rss.is-grid{display:flex;flex-wrap:wrap;padding:0;list-style:none}.wp-block-rss.is-grid li{margin:0 16px 16px 0;width:100%}@media (min-width:600px){.wp-block-rss.columns-2 li{width:calc(50% - 16px)}.wp-block-rss.columns-3 li{width:calc(33.33333% - 16px)}.wp-block-rss.columns-4 li{width:calc(25% - 16px)}.wp-block-rss.columns-5 li{width:calc(20% - 16px)}.wp-block-rss.columns-6 li{width:calc(16.66667% - 16px)}}.wp-block-rss__item-author,.wp-block-rss__item-publish-date{display:block;color:#6c7781;font-size:13px}.wp-block-search{display:flex;flex-wrap:wrap}.wp-block-search .wp-block-search__label{width:100%}.wp-block-search .wp-block-search__input{flex-grow:1;max-width:360px}.wp-block-search .wp-block-search__button{margin-left:10px}.wp-block-separator.is-style-wide{border-bottom-width:1px}.wp-block-separator.is-style-dots{background:none!important;border:0;text-align:center;max-width:none;line-height:1;height:auto}.wp-block-separator.is-style-dots:before{content:"\00b7 \00b7 \00b7";color:currentColor;font-size:20px;letter-spacing:2em;padding-left:2em;font-family:serif}.wp-block-social-links{display:flex;justify-content:flex-start;padding-left:0;padding-right:0;margin-left:0}.wp-block-social-links .wp-social-link a,.wp-block-social-links .wp-social-link a:hover{text-decoration:none;border-bottom:0;box-shadow:none}.wp-social-link{display:block;width:36px;height:36px;border-radius:36px;margin-right:8px;transition:transform .1s ease}@media (prefers-reduced-motion:reduce){.wp-social-link{transition-duration:0s}}.wp-social-link a{padding:6px;display:block;line-height:0;transition:transform .1s ease}.wp-social-link a,.wp-social-link a:active,.wp-social-link a:hover,.wp-social-link a:visited,.wp-social-link svg{color:currentColor;fill:currentColor}.wp-social-link:hover{transform:scale(1.1)}.wp-block-social-links.aligncenter{justify-content:center;display:flex}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link{background-color:#f0f0f0;color:#444}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-amazon{background-color:#f90;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-bandcamp{background-color:#1ea0c3;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-behance{background-color:#0757fe;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-codepen{background-color:#1e1f26;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-deviantart{background-color:#02e49b;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-dribbble{background-color:#e94c89;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-dropbox{background-color:#4280ff;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-etsy{background-color:#f45800;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-facebook{background-color:#1977f2;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-fivehundredpx{background-color:#000;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-flickr{background-color:#0461dd;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-foursquare{background-color:#e65678;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-github{background-color:#24292d;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-goodreads{background-color:#eceadd;color:#382110}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-google{background-color:#ea4434;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-instagram{background-color:#f00075;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-lastfm{background-color:#e21b24;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-linkedin{background-color:#0577b5;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-mastodon{background-color:#3288d4;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-medium{background-color:#02ab6c;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-meetup{background-color:#f6405f;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-pinterest{background-color:#e60122;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-pocket{background-color:#ef4155;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-reddit{background-color:#fe4500;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-skype{background-color:#0478d7;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-snapchat{background-color:#fefc00;color:#fff;stroke:#000}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-soundcloud{background-color:#ff5600;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-spotify{background-color:#1bd760;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-tumblr{background-color:#011835;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-twitch{background-color:#6440a4;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-twitter{background-color:#21a1f3;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-vimeo{background-color:#1eb7ea;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-vk{background-color:#4680c2;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-wordpress{background-color:#3499cd;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-yelp{background-color:#d32422;color:#fff}.wp-block-social-links:not(.is-style-logos-only) .wp-social-link-youtube{background-color:#ff0100;color:#fff}.wp-block-social-links.is-style-logos-only .wp-social-link{background:0 0;padding:4px}.wp-block-social-links.is-style-logos-only .wp-social-link svg{width:28px;height:28px}.wp-block-social-links.is-style-logos-only .wp-social-link-amazon{color:#f90}.wp-block-social-links.is-style-logos-only .wp-social-link-bandcamp{color:#1ea0c3}.wp-block-social-links.is-style-logos-only .wp-social-link-behance{color:#0757fe}.wp-block-social-links.is-style-logos-only .wp-social-link-codepen{color:#1e1f26}.wp-block-social-links.is-style-logos-only .wp-social-link-deviantart{color:#02e49b}.wp-block-social-links.is-style-logos-only .wp-social-link-dribbble{color:#e94c89}.wp-block-social-links.is-style-logos-only .wp-social-link-dropbox{color:#4280ff}.wp-block-social-links.is-style-logos-only .wp-social-link-etsy{color:#f45800}.wp-block-social-links.is-style-logos-only .wp-social-link-facebook{color:#1977f2}.wp-block-social-links.is-style-logos-only .wp-social-link-fivehundredpx{color:#000}.wp-block-social-links.is-style-logos-only .wp-social-link-flickr{color:#0461dd}.wp-block-social-links.is-style-logos-only .wp-social-link-foursquare{color:#e65678}.wp-block-social-links.is-style-logos-only .wp-social-link-github{color:#24292d}.wp-block-social-links.is-style-logos-only .wp-social-link-goodreads{color:#382110}.wp-block-social-links.is-style-logos-only .wp-social-link-google{color:#ea4434}.wp-block-social-links.is-style-logos-only .wp-social-link-instagram{color:#f00075}.wp-block-social-links.is-style-logos-only .wp-social-link-lastfm{color:#e21b24}.wp-block-social-links.is-style-logos-only .wp-social-link-linkedin{color:#0577b5}.wp-block-social-links.is-style-logos-only .wp-social-link-mastodon{color:#3288d4}.wp-block-social-links.is-style-logos-only .wp-social-link-medium{color:#02ab6c}.wp-block-social-links.is-style-logos-only .wp-social-link-meetup{color:#f6405f}.wp-block-social-links.is-style-logos-only .wp-social-link-pinterest{color:#e60122}.wp-block-social-links.is-style-logos-only .wp-social-link-pocket{color:#ef4155}.wp-block-social-links.is-style-logos-only .wp-social-link-reddit{color:#fe4500}.wp-block-social-links.is-style-logos-only .wp-social-link-skype{color:#0478d7}.wp-block-social-links.is-style-logos-only .wp-social-link-snapchat{color:#fff;stroke:#000}.wp-block-social-links.is-style-logos-only .wp-social-link-soundcloud{color:#ff5600}.wp-block-social-links.is-style-logos-only .wp-social-link-spotify{color:#1bd760}.wp-block-social-links.is-style-logos-only .wp-social-link-tumblr{color:#011835}.wp-block-social-links.is-style-logos-only .wp-social-link-twitch{color:#6440a4}.wp-block-social-links.is-style-logos-only .wp-social-link-twitter{color:#21a1f3}.wp-block-social-links.is-style-logos-only .wp-social-link-vimeo{color:#1eb7ea}.wp-block-social-links.is-style-logos-only .wp-social-link-vk{color:#4680c2}.wp-block-social-links.is-style-logos-only .wp-social-link-wordpress{color:#3499cd}.wp-block-social-links.is-style-logos-only .wp-social-link-yelp{background-color:#d32422;color:#fff}.wp-block-social-links.is-style-logos-only .wp-social-link-youtube{color:#ff0100}.wp-block-social-links.is-style-pill-shape .wp-social-link{width:auto}.wp-block-social-links.is-style-pill-shape .wp-social-link a{padding-left:16px;padding-right:16px}.wp-block-spacer{clear:both}p.wp-block-subhead{font-size:1.1em;font-style:italic;opacity:.75}.wp-block-table{overflow-x:auto}.wp-block-table table{width:100%}.wp-block-table .has-fixed-layout{table-layout:fixed;width:100%}.wp-block-table .has-fixed-layout td,.wp-block-table .has-fixed-layout th{word-break:break-word}.wp-block-table.aligncenter,.wp-block-table.alignleft,.wp-block-table.alignright{display:table;width:auto}.wp-block-table.aligncenter td,.wp-block-table.aligncenter th,.wp-block-table.alignleft td,.wp-block-table.alignleft th,.wp-block-table.alignright td,.wp-block-table.alignright th{word-break:break-word}.wp-block-table .has-subtle-light-gray-background-color{background-color:#f3f4f5}.wp-block-table .has-subtle-pale-green-background-color{background-color:#e9fbe5}.wp-block-table .has-subtle-pale-blue-background-color{background-color:#e7f5fe}.wp-block-table .has-subtle-pale-pink-background-color{background-color:#fcf0ef}.wp-block-table.is-style-stripes{border-spacing:0;border-collapse:inherit;background-color:transparent;border-bottom:1px solid #f3f4f5}.wp-block-table.is-style-stripes tbody tr:nth-child(odd){background-color:#f3f4f5}.wp-block-table.is-style-stripes.has-subtle-light-gray-background-color tbody tr:nth-child(odd){background-color:#f3f4f5}.wp-block-table.is-style-stripes.has-subtle-pale-green-background-color tbody tr:nth-child(odd){background-color:#e9fbe5}.wp-block-table.is-style-stripes.has-subtle-pale-blue-background-color tbody tr:nth-child(odd){background-color:#e7f5fe}.wp-block-table.is-style-stripes.has-subtle-pale-pink-background-color tbody tr:nth-child(odd){background-color:#fcf0ef}.wp-block-table.is-style-stripes td,.wp-block-table.is-style-stripes th{border-color:transparent}.wp-block-text-columns,.wp-block-text-columns.aligncenter{display:flex}.wp-block-text-columns .wp-block-column{margin:0 16px;padding:0}.wp-block-text-columns .wp-block-column:first-child{margin-left:0}.wp-block-text-columns .wp-block-column:last-child{margin-right:0}.wp-block-text-columns.columns-2 .wp-block-column{width:50%}.wp-block-text-columns.columns-3 .wp-block-column{width:33.33333%}.wp-block-text-columns.columns-4 .wp-block-column{width:25%}.wp-block-video{margin-left:0;margin-right:0}.wp-block-video video{max-width:100%}@supports ((position:-webkit-sticky) or (position:sticky)){.wp-block-video [poster]{object-fit:cover}}.wp-block-video.aligncenter{text-align:center}.wp-block-video figcaption{margin-top:.5em;margin-bottom:1em}:root .has-pale-pink-background-color{background-color:#f78da7}:root .has-vivid-red-background-color{background-color:#cf2e2e}:root .has-luminous-vivid-orange-background-color{background-color:#ff6900}:root .has-luminous-vivid-amber-background-color{background-color:#fcb900}:root .has-light-green-cyan-background-color{background-color:#7bdcb5}:root .has-vivid-green-cyan-background-color{background-color:#00d084}:root .has-pale-cyan-blue-background-color{background-color:#8ed1fc}:root .has-vivid-cyan-blue-background-color{background-color:#0693e3}:root .has-vivid-purple-background-color{background-color:#9b51e0}:root .has-very-light-gray-background-color{background-color:#eee}:root .has-cyan-bluish-gray-background-color{background-color:#abb8c3}:root .has-very-dark-gray-background-color{background-color:#313131}:root .has-pale-pink-color{color:#f78da7}:root .has-vivid-red-color{color:#cf2e2e}:root .has-luminous-vivid-orange-color{color:#ff6900}:root .has-luminous-vivid-amber-color{color:#fcb900}:root .has-light-green-cyan-color{color:#7bdcb5}:root .has-vivid-green-cyan-color{color:#00d084}:root .has-pale-cyan-blue-color{color:#8ed1fc}:root .has-vivid-cyan-blue-color{color:#0693e3}:root .has-vivid-purple-color{color:#9b51e0}:root .has-very-light-gray-color{color:#eee}:root .has-cyan-bluish-gray-color{color:#abb8c3}:root .has-very-dark-gray-color{color:#313131}:root .has-vivid-cyan-blue-to-vivid-purple-gradient-background{background:linear-gradient(135deg,#0693e3,#9b51e0)}:root .has-vivid-green-cyan-to-vivid-cyan-blue-gradient-background{background:linear-gradient(135deg,#00d084,#0693e3)}:root .has-light-green-cyan-to-vivid-green-cyan-gradient-background{background:linear-gradient(135deg,#7adcb4,#00d082)}:root .has-luminous-vivid-amber-to-luminous-vivid-orange-gradient-background{background:linear-gradient(135deg,#fcb900,#ff6900)}:root .has-luminous-vivid-orange-to-vivid-red-gradient-background{background:linear-gradient(135deg,#ff6900,#cf2e2e)}:root .has-very-light-gray-to-cyan-bluish-gray-gradient-background{background:linear-gradient(135deg,#eee,#a9b8c3)}:root .has-cool-to-warm-spectrum-gradient-background{background:linear-gradient(135deg,#4aeadc,#9778d1 20%,#cf2aba 40%,#ee2c82 60%,#fb6962 80%,#fef84c)}:root .has-blush-light-purple-gradient-background{background:linear-gradient(135deg,#ffceec,#9896f0)}:root .has-blush-bordeaux-gradient-background{background:linear-gradient(135deg,#fecda5,#fe2d2d 50%,#6b003e)}:root .has-purple-crush-gradient-background{background:linear-gradient(135deg,#34e2e4,#4721fb 50%,#ab1dfe)}:root .has-luminous-dusk-gradient-background{background:linear-gradient(135deg,#ffcb70,#c751c0 50%,#4158d0)}:root .has-hazy-dawn-gradient-background{background:linear-gradient(135deg,#faaca8,#dad0ec)}:root .has-pale-ocean-gradient-background{background:linear-gradient(135deg,#fff5cb,#b6e3d4 50%,#33a7b5)}:root .has-electric-grass-gradient-background{background:linear-gradient(135deg,#caf880,#71ce7e)}:root .has-subdued-olive-gradient-background{background:linear-gradient(135deg,#fafae1,#67a671)}:root .has-atomic-cream-gradient-background{background:linear-gradient(135deg,#fdd79a,#004a59)}:root .has-nightshade-gradient-background{background:linear-gradient(135deg,#330968,#31cdcf)}:root .has-midnight-gradient-background{background:linear-gradient(135deg,#020381,#2874fc)}.has-small-font-size{font-size:13px}.has-normal-font-size,.has-regular-font-size{font-size:16px}.has-medium-font-size{font-size:20px}.has-large-font-size{font-size:36px}.has-huge-font-size,.has-larger-font-size{font-size:42px}.has-text-align-center{text-align:center}.has-text-align-left{text-align:left}.has-text-align-right{text-align:right}div.wpcf7 .screen-reader-response{position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);height:1px;width:1px;margin:0;padding:0;border:0}div.wpcf7-response-output{margin:2em .5em 1em;padding:.2em 1em;border:2px solid #f00}div.wpcf7-mail-sent-ok{border:2px solid #398f14}div.wpcf7-mail-sent-ng,div.wpcf7-aborted{border:2px solid #f00}div.wpcf7-spam-blocked{border:2px solid #ffa500}div.wpcf7-validation-errors,div.wpcf7-acceptance-missing{border:2px solid #f7e700}.wpcf7-form-control-wrap{position:relative}span.wpcf7-not-valid-tip{color:#f00;font-size:1em;font-weight:normal;display:block}.use-floating-validation-tip span.wpcf7-not-valid-tip{position:absolute;top:20%;left:20%;z-index:100;border:1px solid #f00;background:#fff;padding:.2em .8em}span.wpcf7-list-item{display:inline-block;margin:0 0 0 1em}span.wpcf7-list-item-label::before,span.wpcf7-list-item-label::after{content:" "}.wpcf7-display-none{display:none}div.wpcf7 .ajax-loader{visibility:hidden;display:inline-block;background-image:url(https://munokuno.com/wp-content/plugins/contact-form-7/includes/css/../../images/ajax-loader.gif);width:16px;height:16px;border:0;padding:0;margin:0 0 0 4px;vertical-align:middle}div.wpcf7 .ajax-loader.is-active{visibility:visible}div.wpcf7 div.ajax-error{display:none}div.wpcf7 .placeheld{color:#888}div.wpcf7 input[type=file]{cursor:pointer}div.wpcf7 input[type=file]:disabled{cursor:default}div.wpcf7 .wpcf7-submit:disabled{cursor:not-allowed}.wpcf7 input[type=url],.wpcf7 input[type=email],.wpcf7 input[type=tel]{direction:ltr}.page-id-21 .sns-share,.page-id-21 .sns-follow,.page-id-33 .sns-share,.page-id-33 .sns-follow,.page-id-129 .sns-share,.page-id-129 .sns-follow{display:none}.widget_categories ul li a{border-bottom:1px dashed #CCC;}.widget_categories ul li a::before{font-family:"Font Awesome 5 Free";font-weight:900;content:"\f07b";color:#5FB3F5;padding-right:6px}.widget_categories>ul>li>a:first-child{border-top:none}.widget_categories ul li ul li a::before{font-family:"Font Awesome 5 Free";font-weight:900;content:"\f15c";color:#5FB3F5;padding-right:6px}.widget_categories ul li a{line-height:1.3}.caption-wrap:hover{font-weight:bold;color:#ffbc00;border-bottom:3px solid #ffd400}.rank-add,.rank-rm{background-color:#ff9}.rank-up{background-color:#d1e8d9}.rank-down{background-color:#f8dadb}td.up{color:#093}td.stay{color:#a6a6a6}td.down{color:#ff333a}div.inline{display:inline-block;_display:inline}.easyLink-info-btn-amazon{background:#F90!important}.easyLink-info-btn-rakuten{background:#BF0000!important}.easyLink-info-btn-yahoo{background:#FF0027!important}#weather{background:linear-gradient(transparent 60%,#ff6 60%)}.ranking{padding:2px 8px;background:#F5DEB3}.ranking-contents{font-size:small;font-weight:bold}.ranking ul{-webkit-flex-direction:column;flex-direction:column;list-style-type:none;margin:0;padding:0}.rank-top li a{display:block;margin:5px 0 12px;padding:.8em;background:#FFF;border-left:solid 10px #093;color:#000;box-shadow:0 3px 3px rgba(0,0,0,.3);background-image:linear-gradient(to right,rgba(0,0,0,0) 50%,#093 50%);background-size:200% auto;background-position:0 0;transition:all .3s ease 0s;text-decoration:none}.rank-top li a:hover{cursor:pointer;background-position:-100% 0;color:#fff}.rank-bottom li a{display:block;margin:5px 0 12px;padding:.8em;background:#FFF;border-left:solid 10px #ff333a;color:#000;box-shadow:0 3px 3px rgba(0,0,0,.3);background-image:linear-gradient(to right,rgba(0,0,0,0) 50%,#ff333a 50%);background-size:200% auto;background-position:0 0;transition:all .3s ease 0s;text-decoration:none}.rank-bottom li a:hover{cursor:pointer;background-position:-100% 0;color:#fff}.rank-title{font-weight:bold;float:left}.rank-num{float:left;background:linear-gradient(transparent 60%,#a8dafb 60%)}.rank-date{text-align:right;}.rank-up-color{color:#093}.rank-down-color{color:#ff333a}.badge-win{color:#fff;padding:1px 5px 0;border-radius:2px;font-size:12px;background-color:#093}.badge-lose{color:#fff;padding:1px 5px 0;border-radius:2px;font-size:12px;background-color:#ff333a}div.psy_nav{font-size:83%}.fa-kunou:before{content:'';height:1.5em;background:url(https://munokuno.com/wp-content/uploads/2019/11/Panda_new3_mobile.png) no-repeat center/contain;display:block}.fa-heart{color:#E3274D;-webkit-font-smoothing:antialiased;-webkit-text-stroke-color:#E3274D;-webkit-text-stroke-width:1.5px}.mobile-menu-buttons{color:#000;background-color:#fffff4;}.sns-share-message-mobile,.sns-follow-message-mobile{padding:3px;font-size:18px;text-align:center;color:#fff;font-weight:bold}.share-menu-content .sns-share-buttons a,.follow-menu-content .sns-follow-buttons a{width:100%}.share-menu-content,.follow-menu-content{top:initial;bottom:20%}@media screen and (max-width:1023px){.logo-header,.tagline{display:none}}#share-menu-input:checked~#share-menu-close,#follow-menu-input:checked~#follow-menu-close{display:block;opacity:.8}.home main,.archive main{background-color:transparent;margin-top:0;padding-top:0}.entry-card-wrap{background-color:#fff;border-radius:4px;margin-bottom:1em!important;box-shadow:0 10px 20px -5px rgba(0,0,0,.2);transition:all .3s ease}.entry-card-wrap:hover{box-shadow:none;transform:translateY(2px);background-color:white}.entry-card-wrap{background-color:#fff;border-radius:4px;margin-bottom:1em!important;box-shadow:0 10px 20px -5px rgba(0,0,0,.2);transition:all .3s ease}.a-wrap{padding:2%}.card-thumb img{border-radius:4px;box-shadow:0 2px 4px -1px rgba(0,0,0,.2)}.eye-catch img{border-radius:4px;box-shadow:0 2px 4px -1px rgba(0,0,0,.2)}.kyusai{padding:15px;background-color:#fff;border-width:3px;border-style:solid;border-color:#00f}.toc-content{visibility:visible;height:auto;opacity:initial;transition:initial}.toc-list li li{visibility:hidden;height:0}.toc-list ol{height:0}.toc-checkbox:checked~.toc-content{padding-top:0}.toc-checkbox:checked~* .toc-list ol{height:auto;padding-left:0;padding-bottom:.8em}.toc-checkbox:checked~* .toc-list li li{visibility:visible;height:auto;margin:0}.toc-list li li:before{font-family:"Font Awesome 5 Free";font-weight:900;content:"\f0da"!important;margin-right:6px}.toc-list li li{list-style:none;text-indent:-11.47px;padding-left:11.47px}.toc-title,.toc-list a{font-weight:bold}.toc-list li li a{font-weight:normal}.toc{min-width:70%;background-color:#FDFEEE;border-style:none;padding:10px 30px 10px 30px;box-shadow:2px 2px 4px gray;background-image:linear-gradient(transparent 98%,rgba(198,206,183,1) 5%),linear-gradient(90deg,transparent 98%,rgba(198,206,183,1) 5%);background-size:14px 14px;background-repeat:repeat;background-position:10px 6px}figcaption{text-align:center;font-size:.8em;margin:2px}.new-navi{position:relative;overflow:hidden;display:block;margin:15px auto;background:#f1f1f1;box-shadow:0 3px 5px rgba(0,0,0,.14);box-sizing:border-box}.new-navi .new-entry-card-title{padding:5px}.ribbon{background:#ec3138;color:#fff;font-size:15px;font-weight:bold;width:400px;height:25px;transform:rotate(-45deg);transform-origin:top center;position:absolute;top:30px;left:-210px;padding:0 0 0 55px;box-sizing:border-box;text-align:center}投資の随筆変なサービス【PHP×MySQL】ランキングナビを自作しました【GAS×Twitter API】自作ツールで相互フォロー解除を監視する市場が開いている日は日本株の投資成績を毎日投稿するようにしています。見に来てくださる方はいるのですが、そのページだけを見て終わる（直帰）パターンが多いです。関連記事も表示していますが投資成績の記事をランダムに見せているだけなので、あまり役立っていません。「暴落した日、暴騰した日がランキング形式で見れたらおもしろいんじゃね？」ってことで自作してみました。汎用性が高いとは言えないですが、ログがてら記事にします。もし、わからない、わかりにくい、うまくいかない等ありましたらコメントください。実装の方法MySQLでランキングナビ用のテーブルを作成HTML、CSSでデザインを作成HTMLを生成するPHPを作成ショートコードとして登録し、設置メンテナンスを楽にするために変更したことメンテナンス用MySQLコマンド前営業日比の増減金額トップ3とワースト3へのリンクを含んだナビゲーション7日以内の記事がランクインしていたら「NEW!」マークを表示見ている記事がランクインしている場合はリンクのタイトルを変更ランキングナビ（PC表示）ランキングナビ（スマホ表示）ランキングナビ（NEWアイコン、閲覧中記事）PHPのバージョン：PHP7.2.17MySQLのバージョン：MySQL5.7ランキングナビ部分の制作は以下のような流れで行いました。上記HTMLを生成するPHPを作成今回の作業は若干難易度が高いです。危機管理なしに「ガンガンいこうぜ」で突き進まないようにお願いします。以下の作業を行っていますので、万が一のミスがあると取り返しがつかなくなることがあります。有事の際に元に戻せるように作業前にバックアップを取ってください。・テーマの基幹となるfunctions.phpに関わる変更・ワードプレスの投稿内容を格納しているMySQLのテーブルからのデータ取得まずはランキングナビ表示のためのデータをMySQLで用意します。以下の項目を持ったテーブルを作成しています。URLのスラッグ部分。日本株の投資成績は「stock-jp-XXXXXX」と日付を使っているのでプライマリーキーとしても利用。投稿の日付。投稿のタイトル。タイトルの最後につけている「[日本株成績XXXXXX]」は入れない。投稿の中身。処理が終わったらNULLにしている。前営業日比の増減金額。continuous_days連騰、続落の連続日数。今回のランキングナビには利用していない。投資結果の天気（晴=1、晴ときどき曇=2、曇=3、雨=4、雷雨=5）。今回のランキングナビには利用していない。投稿が1週間以内かのフラグ。NEWマークの表示に利用。MySQLの操作はエックスサーバーのサーバーパネルから利用できるphpMyAdminを利用しました。phpMyAdminでのMySQLコマンド実行方法SQLタブに以下のコマンドを入力し、実行するとday_change、continuous_days、weatherを除く項目が入ったテーブルが作成できます。今回はwp_stock_jpという名前のテーブルを作成しています。<MySQLコマンド>CREATE TABLE wp_stock_jp (post_name varchar(200) NOT NULL PRIMARY KEY, date varchar(8), title text,post_content longtext, day_change int(7) DEFAULT 0, continuous_days int(2), weather int(1), is_new int(1) DEFAULT 0);	#①INSERT IGNORE INTO wp_stock_jp (post_name, title, post_content) select post_name, post_title,post_content FROM wp_posts WHERE post_status = 'publish' AND post_name like 'stock-jp-%';	#②UPDATE wp_stock_jp SET title=LEFT(title, CHAR_LENGTH(title)-13) WHERE post_content IS NOT null;	#③UPDATE wp_stock_jp SET date=CONCAT("20",RIGHT(post_name, 6)) WHERE post_content IS NOT null;	#④UPDATE wp_stock_jp SET post_content = NULL;	#⑤UPDATE wp_stock_jp SET	#⑥is_new =WHEN date > CURRENT_TIMESTAMP() - INTERVAL 7 DAY THEN 1それぞれのコマンドで以下の処理を行っています。先ほど挙げた項目を持ったテーブルを作成作成したテーブルにワードプレスの投稿情報が入ったテーブルwp_postsから日本株投資成績の投稿を抽出して挿入（post_statusがpublishでスラッグがstock-jp-xxxxxxとなっているレコードを抽出）投稿タイトルから「[日本株成績XXXXXX]」の部分を削除（全体の文字数-13を左側から抽出）スラッグstock-jp-XXXXXXから最後の6桁を抽出し、年を2019とするために20を頭に追加処理が終わったのでpost_contentをNULLに変更dataと現在の日付を比較し、7日以内の場合は1、それ以外は0を入力そして機械的には取得できないday_change、continuous_days、weatherは手入力を行いました。（各投稿を見ながら60弱のレコードを30分かけて入力しました。。）ランキングナビ用テーブル完成イメージランキングナビをどのようなデザインにするかは結構時間がかかりました。2カラムにするコードはCocoonで用意されたものを使っています。<HTMLコード><div class="rank-title">暴騰&暴落日ランキング</div><div class="rank-date"><small><small>（期間：2019/6/24～）</small></small></div><div class="ranking-contents"><div class="wp-block-cocoon-blocks-column-2 column-wrap column-2 column-2-2-1-1 layout-box"><div class="wp-block-cocoon-blocks-column-left column-left"><ul class="rank-top"><li><a href="/XXXXXX/" id="rank-top1"><div class="rank-num">第1位 +XXXXXX</div><div class="rank-date">2019/X/X</div>XXXXX</a></li><li><a href="/XXXXXX/" id="rank-top2"><div class="rank-num">第2位 +XXXXXX</div><div class="rank-date">2019/X/X</div>XXXXX</a></li><li><a href="/XXXXXX/" id="rank-top3"><div class="rank-num">第3位 +XXXXXX</div><div class="rank-date">2019/X/X</div>XXXXX</a></li><div class="wp-block-cocoon-blocks-column-right column-right"><ul class="rank-bottom"><li><a href="/XXXXX/" id="rank-bottom1"><div class="rank-num">第XX位 -XXXXX</div><div class="rank-date">2019/X/X</div>XXXXX</a></li><li><a href="/XXXXX/" id="rank-bottom2"><div class="rank-num">第XX位 -XXXXX</div><div class="rank-date">2019/X/X</div>XXXXX</a></li><li><a href="/XXXXX/" id="rank-bottom3"><div class="rank-num">第XX位 -XXXXX</div><div class="rank-date">2019/X/X</div>XXXXX</a></li><CSSコード>.ranking-contents{.ranking ul {.rank-top li a{margin: 5px 0px 12px;border-left: solid 10px #009933;box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.3);background-image: linear-gradient(to right, rgba(0,0,0,0) 50%, #009933 50%);.rank-top li a:hover {.rank-bottom li a{border-left: solid 10px #ff333a;background-image: linear-gradient(to right, rgba(0,0,0,0) 50%, #ff333a 50%);.rank-bottom li a:hover {.rank-title{.rank-num{/*maker blue*/background: linear-gradient(transparent 60%, #a8dafb 60%);.rank-date{.rank-up-color {.rank-down-color {color: #ff333a;ボタンの縦の配置はフレックスボックスで行っています。.rank-title、.rank-numにfloat: leftを付与し、.rank-dateにtext-align: rightを付与することで1行で左寄せと右寄せを混在させています。上記HTMLを作成するスクリプトをPHPで作成します。ランキングの部分はMySQLのテーブルから情報を引っ張ってきます。MySQLとの接続はPDOで実現する気満々でしたが、ワードプレスでデータベースへのアクセスのために用意されたクラス $wpdbがあることを知ったのでそちらをありがたく使わせてもらいました。下準備として今回作成したwp_stock_jpをwp-db.phpに追記する作業が必要になります。以下の記事を参考に追記しました。blog.yukarien.comPHPファイルは以下を作成しました。<ranking.php>//トップ用code作成$code_top = '<ul class="rank-top">';//day_changeの上位3レコードを取得（結果は配列に格納される）$results = $wpdb->get_results("SELECT * FROM $wpdb->stock_jp ORDER BY day_change DESC LIMIT 3");//ランキングに7日以内の記事が入っているかif ($value->is_new) {$new_mark = '<span class="rank-up-color">NEW!</span> ';$new_mark = '';//ランキングに閲覧中の記事が入っているかif ($value->post_name === substr($_SERVER['REQUEST_URI'], 14, 15)) {$title = '<span class="rank-up-color">本記事です</span>';$code_top = $code_top . '<li><a href="' . '/result/stock/' . $value->post_name . '/" id="rank-top' . $num . '"><div class="rank-num">第' . $num . '位 +' . number_format($value->day_change) . '</div><div class="rank-date">' . $new_mark . date('Y/n/j', strtotime($value->date)) . '</div>';$code_top = $code_top . $title . '</a></li>';$code_top = $code_top . '</ul>';//ワースト用code作成$code_bottom = '<ul class="rank-bottom">';//順位用にレコード数を取得$num_max = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->stock_jp");$results = $wpdb->get_results("SELECT * FROM $wpdb->stock_jp ORDER BY day_change ASC LIMIT 3");$new_mark = '<span class="rank-down-color">NEW!</span> ';$title = '<span class="rank-down-color">本記事です</span>';//idは最下位からrank-bottom1～3を付与$code_bottom = $code_bottom . '<li><a href="' . '/result/stock/' . $value->post_name . '/" id="rank-bottom' . $num . '"><div class="rank-num">第' . $num_max . '位 ' . number_format($value->day_change) . '</div><div class="rank-date">'  . $new_mark . date('Y/n/j', strtotime($value->date)) . '</div>';$code_bottom = $code_bottom . $title . '</a></li>';$num_max--;$code_bottom = $code_bottom . '</ul>';//htmlコードを生成echo<<<eof<div class="ranking"><div class="rank-title">暴騰&暴落日ランキング</div><div class="rank-date"><small><small>（期間：2019/6/24～）</small></small></div><!-- cocoonレイアウト2カラムを使用 --><div class="wp-block-cocoon-blocks-column-2 column-wrap column-2 column-2-2-1-1 layout-box"><!-- wp:cocoon-blocks/column-left -->$code_top<!-- /wp:cocoon-blocks/column-left --></div><!-- wp:cocoon-blocks/column-right -->$code_bottom<!-- /wp:cocoon-blocks/column-right --></div>今回は関係ありませんが、MySQLからデータを取ってくる際に第三者に入力された値を使う場合はprepare()を使ったエスケープ処理が必要になります。7日以内の投稿の場合は「NEW!」アイコンを表示、閲覧中の記事のタイトルは「本記事です」を表示するようにしています。htmlを生成するphpファイルranking.phpが用意できたので、ranking.phpを実行するショートコードを登録します。そのショートコードをお好みの位置に設置すれば実装完了です。ショートコードの登録については、以下の記事で説明しています。設置場所も同じく「投稿本文下」のウィジェットとしました。function.phpを編集しますので万が一のためにバックアップを忘れずに取ってください。【PHP】ページへのアクセスのたびにテキストをランダムで出力ページへアクセスのたびにテキストがランダムで変わる仕組みの実装方法を紹介します。PHPで実現しています。munokuno.com実装についての説明は終わりですが、今回作成するランキングナビは投稿するたびにテーブルへのレコードの追加が必要になります。実装の部分で書きましたが、テーブルの項目は「MySQLコマンドで抽出したもの」と「手入力で対応したもの」がありました。具体的に言うと、以下の3つの項目は手入力での対応としていました。なるべく手入力での対応をなくそうを知恵を絞り、day_changeとweatherについては手入力をなくすことに成功しました。前日比の増減金額の部分にday-change-valueというidを追加しました。天気入力用のショートコードを作成し、引数として天気の数字を使用するように変更しました。（例：[weather 1]）ショートコードの記載は投稿内容にそのまま記載されているので、引数の数字を抽出してテーブルに格納します。function weather($num){if ($num[0] == 1) {$text = '晴';} elseif ($num[0] == 2) {$text = '晴ときどき曇';} elseif ($num[0] == 3) {$text = '曇';} elseif ($num[0] == 4) {$text = '雨';} elseif ($num[0] == 5) {$text = '雷雨';echo '<span id="weather">' . $text . '</span>';add_shortcode('weather', 'weather');別ファイルではなく、function.php内に実行コードを記載しました。レコードの追加およびcontinuous_daysを除く項目の入力までを実行するコマンドが以下になります。日本株投資成績の記事を投稿後、コマンドを実行します。INSERT IGNORE INTO wp_stock_jp (post_name, title, post_content) select post_name, post_title, post_contentFROM wp_posts WHERE post_status = 'publish' AND post_name like 'stock-jp-%';	#①UPDATE wp_stock_jp SET title=LEFT(title, CHAR_LENGTH(title)-13) WHERE post_content IS NOT null;	#②UPDATE wp_stock_jp SET date=CONCAT("20",RIGHT(post_name, 6)) WHERE post_content IS NOT null;	#③UPDATE wp_stock_jp SET weather = SUBSTRING(post_content, LOCATE("weather ", post_content) + CHAR_LENGTH("weather "), 1)WHERE post_content IS NOT null;	#④　※実際のコードではweatherの左側に[がつく（ショートコードが実行されるため除去）UPDATE wp_stock_jp SET post_content = REPLACE(post_content, ",", "") WHERE post_content IS NOT null;	#⑤UPDATE wp_stock_jp SET day_change =SUBSTRING(post_content, LOCATE("day-change-value\">", post_content) + CHAR_LENGTH("day-change-value\">"),LOCATE("<", post_content , LOCATE("day-change-value\">", post_content))-LOCATE("day-change-value\">", post_content) + CHAR_LENGTH("day-change-value\">"))WHERE post_content IS NOT null;	#⑥UPDATE wp_stock_jp SET post_content = NULL;	#⑦UPDATE wp_stock_jp SET	#⑧wp_postsテーブルにpost_nameが重複しないレコードがあれば挿入挿入したレコードの投稿タイトルから「[日本株成績XXXXXX]」の部分を削除※WHERE post_content IS NOT nullを入れることで既存のレコードには実行されないweatherのショートコードの記載から数字を抽出（「[weather 」の次の文字を抽出）前日比の増減金額から「,」を取るために投稿全体から「,」を削除※「,」付きでは抽出がうまくいかなかった前日比の増減金額を抽出（「day-change-value”>」とその次に出てくる「<」の間を抽出）■CASE式で条件分岐をSQL文に任せるhttps://qiita.com/sfp_waterwalker/items/acc7f95f6ab5aa5412f3■【CSS】今更ながら、フレックスボックスの使い方をまとめてみた。https://www.plusdesign.co.jp/blog/?p=8747■ホバー時に背景が左からスライドhttps://haniwaman.com/parts/parts-4117/初めてのMySQLを使ったプラグラムでしたが何とか完成させることができました。ドはまりポイントはこれと言ってありませんでしたが、私にしては大物でしたので時間がかかりました。MySQLについては以下のサイトで勉強しました。MySQL以外にもいろいろな言語が学べるので英語の読みが多少できる人にはお勧めです。以下は実現したかったが技術的に実現できなかった部分なので今後の課題です。ランキングナビ用のDBをワードプレス用のDBと分けて作り、wpdbを利用してアクセスするMySQLのユーザーを追加し、ワードプレス用のDBにはread権限のみ、ランキングナビ用のDBにはread/write権限をつける連騰日数、続落日数をMySQLのコマンドで入力する→9/28追記 実現しました！【MySQL】前のレコードからデータ取得（OFFSET句）メンテナンス用のMySQLのコマンドをワードプレスの画面から実行できるようにする皆さん、せっかく作ったランキングナビを活用してもらえると嬉しいです。（暴騰、暴落の規模が小さくてすみません。。）最後までお読みいただきありがとうございます!PV0を駆逐せよ！にほんブログ村戦略にテコ入れ【PHP×MySQL】サイコロジカルライン出力プラグラムを作成しましたTradingView（トレーディングビュー）という神サービスを利用した株価チャートの掲載方法を説明します。CocoonのプロフィールをTwitter FIRSTにカスタマイズCocoonのプロフィールをカスタマイズし、ツイッターを目立つようにする方法です。【PHP】初回に生成したHTMLコードを再利用して処理を軽くするアクセス毎に同じ内容のHTMLコードを生成していたPHPスクリプトにちょこっと変更を入れて処理を軽くする試みです。興味本位で投資の世界に飛び込み、溺れ続けるリーマン投資家。逆指標として使えます。システムトレード3メタトレーダー53投資の成績99株式91無能投資家観察場8投資の随筆17eワラント1気になるっ！5投資以外の随筆36変なサービス2生産性アップ5【2020年7月】無能投資家観察場（7/2 日本株成績更新）【2020年6月】無能投資家観察場レーティングや目標株価からアナリストの見立てを手に入れる昔NISA口座で囲っていた銘柄を未来から見てむせび泣くCopyright © 2019 無能投資家の苦悩 All Rights Reserved.あなたのシェアが、力になる。
