论坛: 网站建设 标题: 请教:如何调用论坛数据库最新文章?[已知,感谢猪头] 复制本贴地址    
作者: TecZm [teczm]    版主   登录
已知一个论坛
文章按如下格式
  http://x.x.x.x/yyyy/viewtopic.php?t=4

http://x.x.x.x/yyyy/viewtopic.php?t=3

http://x.x.x.x/yyyy/viewtopic.php?t=2  

数字越大,表示发布越新。现在的问题是
如果我在首页显示这个论坛最新的5个帖子的话,我怎么设定t=后面的数字?





[此贴被 TecZm(teczm) 在 11月17日12时20分 编辑过]


[此贴被 TecZm(teczm) 在 11月21日08时47分 编辑过]

地主 发表时间: 05-11-17 12:20

回复: NetFog [q70213526]   版主   登录
PHP俺学懂咯..ASP的还行.

B1层 发表时间: 05-11-17 14:02

回复: TecZm [teczm]   版主   登录
这样的哦 昨天没说清楚

在mysql交互方式下
代码:

mysql>use phpmod;
mysql>select topic_id,forum_id,topic_title from phpbb_topics where forum_id=2 order by topic_id desc limit 2;


可以显示如下:
 
引用:

+----------+----------+-------------+
| topic_id | forum_id | topic_title |
+----------+----------+-------------+
|        4 |        2 | 测试3      |
|        3 |        2 | 测试2      |
+----------+----------+-------------+
2 rows in set (0.03 sec)



我写了一个test.php
代码:

<?php
$dbms = 'mysql4';
$dbhost = 'localhost';
$dbname = 'phpmod';
$dbuser = 'root';
$dbpasswd = '123456'; //密码:)
$table_prefix = 'phpbb_';

define('PHPBB_INSTALLED', true);

$query = "select topic_id,forum_id,topic_title from phpbb_topics where forum_id=2 order by topic_id desc limit 2";

//连接到mysql服务器
$connection =mysql_connect ($dbhost,$dbuser,$dbpasswd);
//打开$dbname数据库
mysql_select_db($dbname,$connection);

$result = mysql_query($query,$connection);

while ($row = mysql_fetch_array($result))
echo $row["topic_title"]; 


显示如下
引用:
测试3测试2

问题是:我现在想让它一行一行的显示
就像这样一样
 
引用:

测试3
测试2


how to?




[此贴被 TecZm(teczm) 在 11月18日10时41分 编辑过]

B2层 发表时间: 05-11-18 10:40

回复: TecZm [teczm]   版主   登录
上1贴的问题解决了
代码:

echo "{$row["topic_title"]}<br>";




[此贴被 TecZm(teczm) 在 11月18日10时57分 编辑过]

B3层 发表时间: 05-11-18 10:57

回复: TecZm [teczm]   版主   登录
比如 我现在要把
测试3
测试2
全部加上链接,点链接都打开www.20cn.net的话
HOW TO?

我这样,错误。
代码:

echo "<a href="http://www.20cn.net"> <?php echo "{$row["topic_title"]}<br>";  ?> </a>"





B4层 发表时间: 05-11-18 12:15

回复: NetFog [q70213526]   版主   登录
头晕.PHP不懂..有时间再学学.没时间就不学了咯..

B5层 发表时间: 05-11-18 13:00

回复: TecZm [teczm]   版主   登录
上个问题也解决了
代码:

<?php
include 'config.php';
$query = "select topic_id,forum_id,topic_title from phpbb_topics where forum_id=2 order by topic_id desc limit 2";
//连接到mysql服务器
$connection =mysql_connect ($dbhost,$dbuser,$dbpasswd);
//打开$dbname数据库
mysql_select_db($dbname,$connection);
$result = mysql_query($query,$connection);
while ($row = mysql_fetch_array($result))
{
//连接到20cn
echo "<a href=http://www.20cn.net>".$row["topic_title"]."</a><br>";
}
?>


新问题是:我怎么连接到相关的帖子呢?
我用下面这个,错误
代码:

echo "<a href=./viewtopic.php?t=$row["topic_id"]>".$row["topic_title"]."</a><br>";




ps:NetFog [q70213526]不懂就不要回帖了么

[此贴被 TecZm(teczm) 在 11月18日13时07分 编辑过]

B6层 发表时间: 05-11-18 13:05

回复: NetDemon [netdemon]   ADMIN   登录
echo "<a href=viewtopic.php?t=$row['topic_id']>$row['topic_title']</a><br>";


B7层 发表时间: 05-11-19 20:12

回复: NetDemon [netdemon]   ADMIN   登录
或者

echo "<a href=viewtopic.php?t=".$row["topic_id"].">".$row["topic_title"]."</a><br>";


B8层 发表时间: 05-11-19 20:16

回复: TecZm [teczm]   版主   登录
echo "<a href=viewtopic.php?t=".$row["topic_id"].">".$row["topic_title"]."</a><br>";
红色部分.是字符串连接用的,""是做什么的呢?

明白了 谢谢

[此贴被 TecZm(teczm) 在 11月21日08时47分 编辑过]

B9层 发表时间: 05-11-19 20:30

论坛: 网站建设

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号