我有while循环,并且有论坛帖子。我想显示帖子数量(1,2 ..)。
让我告诉你我的想法
while($some = mysql_fetch_array($forum_posts)){
echo 'Number of post is $num++';
}
并显示为
------线程-------
------帖子-------
Text of post 1.
Text of post 2.
Text of post 3.
谢谢。不好的英语
答案 0 :(得分:10)
$ num必须初始化!
$num = 1;
while($some = mysql_fetch_array($forum_posts)){
echo 'Number of post is '.($num++);
}
答案 1 :(得分:2)
$num = 0;
while($some = mysql_fetch_array($forum_posts)){
echo 'Number of post is '.++$num;
}
答案 2 :(得分:0)
尝试:
$num = 1;
while($some = mysql_fetch_array($forum_posts)){
echo 'Number of post is ' . ($num++) . '.';
}
变量必须在字符串之外。