TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-19-2009, 10:39 AM   #1 (permalink)
The Wanderer
 
Join Date: Aug 2009
Posts: 15
Thanks: 11
tearsofthesun is on a distinguished road
Default 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
tearsofthesun is offline  
Reply With Quote
Old 08-19-2009, 11:04 AM   #2 (permalink)
The Acquainted
 
JaoudeStudios's Avatar
 
Join Date: Jul 2009
Location: Surrey
Posts: 105
Thanks: 1
JaoudeStudios is on a distinguished road
Default

Yes you need to add a WHERE condition, otherwise you will get all the results in that table.
...WHERE author_id = 'x'
__________________
JaoudeStudios.com | JaoudeStudios.com Forum | JaoudeStudios.com Blog
OpenSource is the road ahead...!
JaoudeStudios is offline  
Reply With Quote
Old 08-19-2009, 08:47 PM   #3 (permalink)
The Wanderer
 
Join Date: Aug 2009
Posts: 15
Thanks: 11
tearsofthesun is on a distinguished road
Default

how would i do that?
tearsofthesun is offline  
Reply With Quote
Old 08-21-2009, 11:27 PM   #4 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

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.
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Timestamps in SQL? Theo Absolute Beginners 2 08-23-2008 04:27 AM
Adding text to a file.. Tanax Absolute Beginners 2 04-17-2008 05:25 AM
Adding Images to a database from a folder Rendair Advanced PHP Programming 3 01-13-2008 07:40 PM
MySQL Query; Counting and adding values ReSpawN Absolute Beginners 3 12-11-2007 10:07 PM


All times are GMT. The time now is 01:30 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design