Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8973913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:33:23+00:00 2026-06-15T18:33:23+00:00

Table – Messages +——————————————————————————————–+ | msg_id | message | uid_fk | ip | created

  • 0
Table - Messages
+--------------------------------------------------------------------------------------------+
| msg_id | message | uid_fk | ip | created | uploads|
|  554  Blah....    35     ..  1355000068   0   |
|  555  Blah....    34     ..  1355002587   0   |
|  553  Blah....    34     ..  1354990968   0   |
+--------------------------------------------------------------------------------------------+

What I’m trying to do is get uid_fk and sum it all up, and then be able to echo it using php.
The uid_fk is the user uid in another table called users with some other data. I’m not sure at all how to sum it both together by getting their specific ID’s.

I started with this but I’m pretty new with MySQL databases.

    public function Total_Posts($uid){
        $query          = mysql_query("SELECT uid_fk, sum(count) as sum from messages group by uid_fk");
        $num            = mysql_fetch_array($query);
        $return $num;
}

UPDATE: Working Version

    public function Total_Posts($uid){
        $messages       = mysql_query("SELECT * FROM messages WHERE uid_fk='$uid'");
        $numrows        = mysql_num_rows($messages);
        return $numrows;
    }

    <?php 
        $Total_Posts        = $Wall->Total_Posts($uid,$total);
    ?>

    <?php echo $Total_Posts; ?>

Seems to work great, thank you for all the help.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:33:25+00:00Added an answer on June 15, 2026 at 6:33 pm

    get all the elements you need:

    $messages = mysql_query("SELECT * FROM Messages WHERE uid_fk='$uid'");
    

    then sum:

    $sum=0;
    while ($message = mysql_fetch_array($messages)){
        $sum += $message['uid_fk'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Table is created, but rows are empty, why? MySqlConnection conn = new MySqlConnection(...); conn.Open();
Table row example: <tr class=row><td>Blah</td><td>Blah 2</td></tr> how to go from here: $('row').click(function(){ }); So
table : id (integer primary key) data (blob) I use mysql and sqlalchemy. To
Table --------------------------------------------- | id | first_name | middle_name | last_name | --------------------------------------------- | 1
Table structure id (p) | date | id2 (fk) | id3 (fk) where (p)
Table A has two columns: ID and name I want to input 3 ID
Table #1: qa_returns_items Table #2: qa_returns_residues I have a long time trying to get
Table: items Create Table: CREATE TABLE `items` ( `ite_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
table is CREATE TABLE `news` ( `id` bigint(20) NOT NULL auto_increment, `title` varchar(255) default
TABLE 1 id time1 info 1 110 info1 2 120 info2 TABLE 2 id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.