时间:2010-01-30 02:13:35

标签: php mysql

我是MySQL的新手,所以我需要一些帮助,

我有一个名为“posts”的表,此表包含以下列:

id - 这是自动增量和主键
标题
内容

我有一个PHP页面,我想显示数据库表中的所有帖子。我希望首先显示标题,然后是帖子内容,然后是下一篇文章的标题,它的帖子内容等等......但是,如果我这样做:

$select = mysql_query("SELECT * FROM posts ORDER BY id DESC");

while ($result = mysql_fetch_array($select))
{
   echo $result['title'] . "<br />";
   echo $result['content'];
}

当然,我会得到所有帖子标题的列表,然后是我的所有帖子内容。换句话说就是这样:

DogsCats

Are also known as canines.Are also known as felines.

Instead of:

Dogs

Are also known as canines

Cats

Are also known as felines

我需要做些什么来解决这个问题?

非常感谢。

3 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

答案 2 :(得分:0)