PHP制作唯一的链接


PHP making unique link

我想做一个博客类型的系统,你点击其中一个博客条目的标题,你将被重定向到完整的文章。我使用substr来显示文章的一部分。问题是href标签没有做任何事情,所以读者无法阅读全文。如果有人能帮忙,那就太好了。

<?php   
$dbinfo = "SELECT title, date, body FROM content ORDER BY blog_id DESC";
$result = mysql_query($dbinfo);
while($data=mysql_fetch_row($result)){
echo substr("<h1>$data[0]</h1><br> <b>$data[1]</b><br> $data[2]", 0, 97)." ... "." read more<br><br><hr>";
echo '<a href="index.php?id=' . $result['blog_id'] . '">' . $result['title'] . ' </a>';
}
?>

亲爱的你不能使用$result['blog_id']

你必须使用$data[index]并且索引必须是0或1或2…

<?php
$dbinfo = "select blog_id,title,date,body from content order by blog_id DESC"
$result = mysql_query($dbinfo) or die("cann't execute query");
$num = mysql_num_rows($result)
$i=0;
while($i < $num)
{
$blog_id = mysql_result($result,$i,'blog_id');
$title = mysql_result($result,$i,'title');
$date = mysql_result($result,$i,'date');
$body = mysql_result($result,$i,'body');
$i++
echo '<h1>'.$title.'</h1><small> ('.$data.') </small>';
echo '<p>'.substr($body,0,100).'<p>';
echo '<a href"index.php?id='.$blog_id.'"> Read More </a>';
}
?>

但是亲爱的,我不喜欢在这里做substr,我更喜欢做一些文本摘要算法,看看这里http://www.binpress.com/app/php-summarizer/87http://www.tools4noobs.com/summarize/script/

如果你不想做总结你可以使用爆炸和内爆函数来获取特定数量的单词并显示它们