我正在尝试在页面上创建一些“动态”链接。基本上我想删除我所在页面的链接。(例如,如果我在主页上,我不希望显示主页链接,但如果我在 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; }
你们可以提供的任何帮助将不胜感激