ページに「動的」リンクを作成しようとしています。基本的に、私がいるページのリンクをドロップしたいです。(たとえば、ホームページにいる場合はホーム リンクを表示したくありませんが、FAQ ページにいる場合はホーム リンクが表示され、FAQ リンクは表示されません。) このコードは希望どおりに機能します。それほど多くのコードを複製しないより良い方法が必要だと思いますが、私の限られたプログラミング経験ではそれを見ることができます.
<div class= "links">
<?php
switch ($page_title) {
case 'Home':
echo '<p class= "who">'.
'<a href="whois.php" tabindex="1"><img src= "images/WhoIs.png" alt= "Who is BeeCharmer" /></a>'.
'</p>';
echo '<p class= "contact">'.
'<a href="contact.php" tabindex="2"><img src= "images/ContactUs.png" alt= "Contact Us" /></a>'.
'</p>';
echo '<p class= "what">'.
'<a href="whatwedo.php" tabindex="3"><img src= "images/WhatWeDo.png" alt= "What Does BeeCharmer Do" /></a>'.
'</p>';
echo '<p class ="FAQ">'.
'<a href="faq.php" tabindex="4"><img src= "images/FAQ.png" alt= "Frequently Asked Questions" /></a>'.
'</p>';
echo '<p class= "pics">'.
'<a href="gallery.php" tabindex="5"><img src= "images/gallery.png" alt= "Photo Gallery" /></a>'.
'</p>';
echo '<p class= "pollination">'.
'<a href="pollination.php" tabindex="6"><img src= "images/Pollination.png" alt= "Pollination Services" /></a>'.
'</p>';
echo '<p class= "pay">'.
'<a href="payus.php" tabindex="7"><img src= "images/PayUs.png" alt= "Pay BeeCharmer" /></a>'.
'</p>';
break;
case 'Who is BeeCharmer':
echo '<p class= "home">'.
'<a href="index.php" tabindex="1"><img src= "images/HomePage.png" alt= "Home Page" /></a>'.
'</p>';
echo '<p class= "contact">'.
'<a href="contact.php" tabindex="2"><img src= "images/ContactUs.png" alt= "Contact Us" /></a>'.
'</p>';
echo '<p class= "what">'.
'<a href="whatwedo.php" tabindex="3"><img src= "images/WhatWeDo.png" alt= "What Does BeeCharmer Do" /></a>'.
'</p>';
echo '<p class ="FAQ">'.
'<a href="faq.php" tabindex="4"><img src= "images/FAQ.png" alt= "Frequently Asked Questions" /></a>'.
'</p>';
echo '<p class= "pics">'.
'<a href="gallery.php" tabindex="5"><img src= "images/gallery.png" alt= "Photo Gallery" /></a>'.
'</p>';
echo '<p class= "pollination">'.
'<a href="pollination.php" tabindex="6"><img src= "images/Pollination.png" alt= "Pollination Services" /></a>'.
'</p>';
echo '<p class= "pay">'.
'<a href="payus.php" tabindex="7"><img src= "images/PayUs.png" alt= "Pay BeeCharmer" /></a>'.
'</p>';
break;
case 'Contact Us':
echo '<p class= "home">'.
'<a href="index.php" tabindex="1"><img src= "images/HomePage.png" alt= "Home Page" /></a>'.
'</p>';
echo '<p class= "who">'.
'<a href="whois.php" tabindex="2"><img src= "images/WhoIs.png" alt= "Who is BeeCharmer" /></a>'.
'</p>';
echo '<p class= "what">'.
'<a href="whatwedo.php" tabindex="3"><img src= "images/WhatWeDo.png" alt= "What Does BeeCharmer Do" /></a>'.
'</p>';
echo '<p class ="FAQ">'.
'<a href="faq.php" tabindex="4"><img src= "images/FAQ.png" alt= "Frequently Asked Questions" /></a>'.
'</p>';
echo '<p class= "pics">'.
'<a href="gallery.php" tabindex="5"><img src= "images/gallery.png" alt= "Photo Gallery" /></a>'.
'</p>';
echo '<p class= "pollination">'.
'<a href="pollination.php" tabindex="6"><img src= "images/Pollination.png" alt= "Pollination Services" /></a>'.
'</p>';
echo '<p class= "pay">'.
'<a href="payus.php" tabindex="7"><img src= "images/PayUs.png" alt= "Pay BeeCharmer" /></a>'.
'</p>';
break;
case 'What We Do':
echo '<p class= "home">'.
'<a href="index.php" tabindex="1"><img src= "images/HomePage.png" alt= "Home Page" /></a>'.
'</p>';
echo '<p class= "who">'.
'<a href="whois.php" tabindex="2"><img src= "images/WhoIs.png" alt= "Who is BeeCharmer" /></a>'.
'</p>';
echo '<p class= "contact">'.
'<a href="contact.php" tabindex="3"><img src= "images/ContactUs.png" alt= "Contact Us" /></a>'.
'</p>';
echo '<p class ="FAQ">'.
'<a href="faq.php" tabindex="4"><img src= "images/FAQ.png" alt= "Frequently Asked Questions" /></a>'.
'</p>';
echo '<p class= "pics">'.
'<a href="gallery.php" tabindex="5"><img src= "images/gallery.png" alt= "Photo Gallery" /></a>'.
'</p>';
echo '<p class= "pollination">'.
'<a href="pollination.php" tabindex="6"><img src= "images/Pollination.png" alt= "Pollination Services" /></a>'.
'</p>';
echo '<p class= "pay">'.
'<a href="payus.php" tabindex="7"><img src= "images/PayUs.png" alt= "Pay BeeCharmer" /></a>'.
'</p>';
break;
case 'FAQ':
echo '<p class= "home">'.
'<a href="index.php" tabindex="1"><img src= "images/HomePage.png" alt= "Home Page" /></a>'.
'</p>';
echo '<p class= "who">'.
'<a href="whois.php" tabindex="2"><img src= "images/WhoIs.png" alt= "Who is BeeCharmer" /></a>'.
'</p>';
echo '<p class= "contact">'.
'<a href="contact.php" tabindex="3"><img src= "images/ContactUs.png" alt= "Contact Us" /></a>'.
'</p>';
echo '<p class= "what">'.
'<a href="whatwedo.php" tabindex="4"><img src= "images/WhatWeDo.png" alt= "What Does BeeCharmer Do" /></a>'.
'</p>';
echo '<p class= "pics">'.
'<a href="gallery.php" tabindex="5"><img src= "images/gallery.png" alt= "Photo Gallery" /></a>'.
'</p>';
echo '<p class= "pollination">'.
'<a href="pollination.php" tabindex="6"><img src= "images/Pollination.png" alt= "Pollination Services" /></a>'.
'</p>';
echo '<p class= "pay">'.
'<a href="payus.php" tabindex="7"><img src= "images/PayUs.png" alt= "Pay BeeCharmer" /></a>'.
'</p>';
break;
case 'Photo Gallery':
echo '<p class= "home">'.
'<a href="index.php" tabindex="1"><img src= "images/HomePage.png" alt= "Home Page" /></a>'.
'</p>';
echo '<p class= "who">'.
'<a href="whois.php" tabindex="2"><img src= "images/WhoIs.png" alt= "Who is BeeCharmer" /></a>'.
'</p>';
echo '<p class= "contact">'.
'<a href="contact.php" tabindex="3"><img src= "images/ContactUs.png" alt= "Contact Us" /></a>'.
'</p>';
echo '<p class= "what">'.
'<a href="whatwedo.php" tabindex="4"><img src= "images/WhatWeDo.png" alt= "What Does BeeCharmer Do" /></a>'.
'</p>';
echo '<p class ="FAQ">'.
'<a href="faq.php" tabindex="5"><img src= "images/FAQ.png" alt= "Frequently Asked Questions" /></a>'.
'</p>';
echo '<p class= "pollination">'.
'<a href="pollination.php" tabindex="6"><img src= "images/Pollination.png" alt= "Pollination Services" /></a>'.
'</p>';
echo '<p class= "pay">'.
'<a href="payus.php" tabindex="7"><img src= "images/PayUs.png" alt= "Pay BeeCharmer" /></a>'.
'</p>';
break;
case 'Pollination Services':
echo '<p class= "home">'.
'<a href="index.php" tabindex="1"><img src= "images/HomePage.png" alt= "Home Page" /></a>'.
'</p>';
echo '<p class= "who">'.
'<a href="whois.php" tabindex="2"><img src= "images/WhoIs.png" alt= "Who is BeeCharmer" /></a>'.
'</p>';
echo '<p class= "contact">'.
'<a href="contact.php" tabindex="3"><img src= "images/ContactUs.png" alt= "Contact Us" /></a>'.
'</p>';
echo '<p class= "what">'.
'<a href="whatwedo.php" tabindex="4"><img src= "images/WhatWeDo.png" alt= "What Does BeeCharmer Do" /></a>'.
'</p>';
echo '<p class ="FAQ">'.
'<a href="faq.php" tabindex="5"><img src= "images/FAQ.png" alt= "Frequently Asked Questions" /></a>'.
'</p>';
echo '<p class= "pics">'.
'<a href="gallery.php" tabindex="6"><img src= "images/gallery.png" alt= "Photo Gallery" /></a>'.
'</p>';
echo '<p class= "pay">'.
'<a href="payus.php" tabindex="7"><img src= "images/PayUs.png" alt= "Pay BeeCharmer" /></a>'.
'</p>';
break;
case 'Pay Us':
echo '<p class= "home">'.
'<a href="index.php" tabindex="1"><img src= "images/HomePage.png" alt= "Home Page" /></a>'.
'</p>';
echo '<p class= "who">'.
'<a href="whois.php" tabindex="2"><img src= "images/WhoIs.png" alt= "Who is BeeCharmer" /></a>'.
'</p>';
echo '<p class= "contact">'.
'<a href="contact.php" tabindex="3"><img src= "images/ContactUs.png" alt= "Contact Us" /></a>'.
'</p>';
echo '<p class= "what">'.
'<a href="whatwedo.php" tabindex="4"><img src= "images/WhatWeDo.png" alt= "What Does BeeCharmer Do" /></a>'.
'</p>';
echo '<p class ="FAQ">'.
'<a href="faq.php" tabindex="5"><img src= "images/FAQ.png" alt= "Frequently Asked Questions" /></a>'.
'</p>';
echo '<p class= "pics">'.
'<a href="gallery.php" tabindex="6"><img src= "images/gallery.png" alt= "Photo Gallery" /></a>'.
'</p>';
echo '<p class= "pollination">'.
'<a href="pollination.php" tabindex="7"><img src= "images/Pollination.png" alt= "Pollination Services" /></a>'.
'</p>';
break;
}
?>
スタイルを設定する CSS は次のとおりです。
div.links { width: 40%;
position: absolute;
top: 280px;
left: 2%; }
div.links p img { border: none;
position: relative;
top: -29px;
left: 5px; }
div.links p { background-image: url("../images/yellowSlidingDoorleft.png"),
url("../images/yellowSlidingDoorRight.png"),
url("../images/yellowSlidingDoorMiddle.png");
background-position: top left, top right, top center;
background-repeat: no-repeat, no-repeat, repeat;
height: 38px;
width: 520px;
border: none;
overflow: hidden; }
/*div.links p.home { position: relative;
top: 0px;
left: 0px; }
div.links p.who { position: relative;
top: 50px;
left: 0px; }
div.links p.contact { position: relative;
top: 100px;
left: 0px; }
div.links p.what { position: relative;
top: 150px;
left: 0px; }
div.links p.FAQ { position: relative;
top: 200px;
left: 0px; }
div.links p.pics { position: relative;
top: 250px;
left: 0px; }
div.links p.pollination { position: relative;
top: 300px;
left: 0px; }
div.links p.pay { position: relative;
top: 350px;
left: 0px; }*/
div.links p:hover img { position: relative;
top: 5px;
left: 5px; }
div.links p:hover { background-image: url("../images/blackSlidingDoorleft.png"),
url("../images/blackSlidingDoorRight.png"),
url("../images/blackSlidingDoorMiddle.png");
background-position: top left, top right, top center;
background-repeat: no-repeat, no-repeat, repeat; }
皆さんが与えることができるどんな助けも本当に感謝しています