Hi, I have something like a thread that has posts inside of it. I want to display what post number it is in each post. But in every thread the count should start from zero again like in this forums. How can I do that? Thanks in advance
just keep a seperate variable that you ++ each time you output the posts. You have to be reading the posts from a DB or something, so you would foreach ( post ) postvar++ output( postcontent ) Code (markup):
Thanks for the reply, I don't really know how to use foreach();. I am using mysql to display the posts. Each post has a unique ID. How will I code that? $post_id = $row["pid"]; foreach($post_id) $count_post++ output($post_id) PHP: Am I close? and will this work inside while(); ?
Just to a search on google for foreach() you can also do this in a while loop, fetching each row of the sql query $post_count=0; while($row = fetch_array()){ echo $row['content']; echo $row['pid']; echo $post_count; $post_count++; } Code (markup):