首先,我想说明我对php很新。
我正在使用XAMPP开发一个站点,我有一些代码将MySQL数据库中的值吐出到php页面上。问题是,有些链接似乎不起作用。在浏览器中,它们不作为链接显示,当您将鼠标悬停在它们上方时,光标将保持为箭头状态。我检查了源代码,所有似乎都没问题。我一直在摆弄根文件夹中的.htaccess文件,如果这与它有关。
//This link works just fine
echo "<div class='catname'><a href='".ROOTLINK."$caturl' class='caturllink'>".$catname."</a></div> \n";
//These are not working
echo "<div class='cat_post main'> \n
<h1><a href='" . ROOTLINK . $posturl . "' class='cat_post_link' >".$title."</a></h1> \n
<a href='" . ROOTLINK . $posturl . "' ><img src='".ROOTLINK.$photourl."' /></a> \n
<p><a href='" . ROOTLINK . $posturl . "' class='cat_post_link' >".$text."</a></p> \n
<br class='clear' /> <!-- <<<<<<< VERY IMPORTANT --> \n
</div> \n";
ROOTLINK变量定义为http://localhost/
。
源代码如下所示:
<div class='catname'><a href='http://localhost/sport' class='caturllink'>SPORT</a></div>
<div class='cat_post main'>
<h1><a href='http://localhost/sport/20140727120738-commonwealth-games-kick-off.php' class='cat_post_link' >Commonwealth Games kick off</a></h1>
<a href='http://localhost/sport/20140727120738-commonwealth-games-kick-off.php' ><img src='http://localhost//images/test/phpB206-20140727120738.jpg' /></a>
<p><a href='http://localhost/sport/20140727120738-commonwealth-games-kick-off.php' class='cat_post_link' >Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vivamus faucibus nunc eleifend nunc sodales tempor. Nullam non enim risus. Praesent vel ante id diam venenatis tincidunt. Vivamus scelerisque, purus ac volutpat blandit, massa nunc feugiat justo, ut iaculis massa nibh at neque. Nunc id quam ut turpis blandit viverra. Nam sagittis, mi ut pulvinar posuere, diam ligula posuere …</a></p>
<br class='clear' /> <!-- <<<<<<< VERY IMPORTANT -->
</div>
CSS:
div.cat_post.main { display: block; border-bottom:2px solid #BE420E; padding-bottom: 15px; margin-bottom: 10px; }
div.cat_post.main img { width: 300px; height: 169px; background-color: #AAA; float: left; margin-right:10px;}
div.cat_post.main p { float: right; width: 300px; height: 169px; margin: 0 10px 0; }
a.cat_post_link { color: #666666; }
.catname { background-color: #FFF68F; font-size: 24px; color: #BE420E; margin-bottom: 10px; padding: 5px 5px 5px 10px; font-weight: bold;}
.caturllink { background: inherit; text-transform: uppercase; }
答案 0 :(得分:0)
我意识到侧边栏中的结束</div>
标签丢失了,一旦我重新添加它,一切都恢复正常。简单但有害。