TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Adding two coulmns (http://www.talkphp.com/advanced-php-programming/4872-adding-two-coulmns.html)

tearsofthesun 08-19-2009 10:39 AM

Adding two coulmns
 
I'm trying to get the total post of a user in my forum but my code doesn't work.

PHP Code:

<?php
$query 
mysql_query('SELECT author, post, COUNT(*) FROM forum_posts') or die (mysql_error());
$result mysql_result($query) or die (mysql_error());;
echo 
'$result';
?>

EX: adding author and post = 25 or something like that :'-(

JaoudeStudios 08-19-2009 11:04 AM

Yes you need to add a WHERE condition, otherwise you will get all the results in that table.
...WHERE author_id = 'x'

tearsofthesun 08-19-2009 08:47 PM

how would i do that?

rguy84 08-21-2009 11:27 PM

just what Jaoude said...

...FROM forum_posts WHERE author_id = '$Author_id'

we are assuming forum_posts has the following fields
post_id //primary key
thread_id // foreign key linked to a table holding the thread title
author_id // foreign key linked to a table w/ author/usernames
post // body of that post.


All times are GMT. The time now is 07:52 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0