5

I have while loop and in that there's forum posts.I want to show number of posts (1,2..).

Let me show you what i think

while($some = mysql_fetch_array($forum_posts)){
echo 'Number of post is $num++';
}

and show like

------ Thread -------

------ Posts -------

Text of post            1.
Text of post            2.
Text of post            3.

Thanks.Sorry for bad english

3 Answers 3

12

$num must be initialized!

$num = 1;
while($some = mysql_fetch_array($forum_posts)){
echo 'Number of post is '.($num++);
}
Sign up to request clarification or add additional context in comments.

Comments

2
$num = 0;

while($some = mysql_fetch_array($forum_posts)){
    echo 'Number of post is '.++$num;
}

Comments

0

Try with:

$num = 1;
while($some = mysql_fetch_array($forum_posts)){
   echo 'Number of post is ' . ($num++) . '.';
}

Variables have to be outside string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.