ok.
SELECT phpbb_users FROM user_posts WHERE user_posts.phpbb_users = $forumusername;
is what you have.
This will select all the records in the column phpbb_users from the table user_posts where the field users_posts = forumusername.
This is a fairly good try, but I'm not sure it's what you wanted.
It helps to think in terms of how the database works. I think if I can explain that, it may help you a lot.
Think of it just like an HTML table.
You have columns (fields) and rows (records).
If you SELECT * (select all) from a table, you are selecting all of the columns (fields) from the table.
For example if we had a table like this:
tablename: demo
Food | Color | Type
-------------------------------------------
banana | yellow | fruit
and we said "SELECT * FROM demo" we would get as a result:
banana, yellow, fruit.
if we said "SELECT Food FROM demo", we would get:
banana
if we said "SELECT Color, Type FROM demo"
we would get yellow, fruit
if we said "SELECT Type, Food FROM demo", we would get:
fruit, banana.
Remember, you never scroll over to the field. You don't look in a field. You tell the database which fields you want.
We told the database we want field Food or Color or whatever.
In your case, we are only interested in the number of posts. This is represented by the field user_posts . We don't want all the fields, we only want that one.
The next part of this can be feel kind of funny when first understanding it. This is our condition part.
In our demo table above, we only had one record. Therefore, we only got one record when we asked for records.
Let's add more records
tablename: demo
Food | Color | Type
--------------------------------------------
banana | yellow | fruit
orange | orange | fruit
brocoli | green | vegetable
steak | brown | meat
lemon | yellow | fruit
Now,
if we said "SELECT * FROM demo", we would get everything in our results.
We can use it, but it's a little confusing. We only want the names.
To get all the names, it's like this:
"SELECT Food from demo" this would return:
banana, orange, brocoli, steak, lemon
likewise, if we said:
"SELECT Type, Color FROM demo" we would get:
fruit, yellow
fruit, orange
vegetable, green
meat, brown
fruit, yellow
Hopefully, you understand how you request certain columns.
The columns you specify upfront is the ONLY place you specify which columns will output. In fact, you might think of it as formatting your output.
If we wanted all the fruit that is yellow, we need a way to test which ones are yellow.
Moreover, since we know how to format which columns are shown, we are only interested in the names (the Food column).
hmmm yellow is found in the Color column and the name is found in the Food column. So... we are testing the Color column, and outputting the Food column.
If we say:
"SELECT Food from demo WHERE Color = 'yellow'";
we will get:
banana, lemon
What this basically does is look in every row. It doesn't scroll across columns or anything like that. It goes down the rows. Whenever the column Color = yellow, it saves whatever is in the Food column.
"SELECT Food from demo WHERE Type = 'meat'";
will return:
steak
This seems similar to the type of problem you want to solve.
SELECT user_posts FROM phpbb_users WHERE user_id = $id
This will do the same thing. It's starts scrolling down the rows. Whenever the column user_id = $id, it saves user_posts to output later on. The only thing returned by this is user_posts.
I hope this helped your understanding...
seriously, ask questions if you still have any. It's a really important concept to understand.