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

  • Home
  • SEARCH
  • 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 4033700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:52:47+00:00 2026-05-20T11:52:47+00:00

With the first query in the following code I am looking for the checkings

  • 0

With the first query in the following code I am looking for the checkings made in Berlin under the game number two.

With the second query I want to give points for each of the checkings.

As you will see I am using the function SUM. But let’s say that I have 2 checkings and the points for each checking are 50. Well, instead of echoing 100, with this code I echo 5050

What is wrong with it?

Thanks a lot

THE CODE IS CORRECTED AND WORKING, JUST IN CASE SOMEBODY NEEDS IT. Thanks to all

       $querya = "SELECT * FROM checkins where gamesid=2 and city='Berlin'";
 $resulta = mysql_query($querya) or die(mysql_error());

 $sumOfPoints = 0;
 while($rowa = mysql_fetch_array($resulta)){

      $n = $rowa['venuesid'];
      $queryb = "SELECT venuesid, SUM(points) as sumpoints from venues where venuesid='".$n."' GROUP BY venuesid ORDER BY venuesid";
      $resultb = mysql_query($queryb) or die(mysql_error());

      while($rowb = mysql_fetch_array($resultb)){

           $sumOfPoints +=  $rowb['sumpoints'];

      }

 }


  echo "Total points is $sumOfPoints<br/>";
  • 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-05-20T11:52:47+00:00Added an answer on May 20, 2026 at 11:52 am

    Some suggestions

    1. Use SUM(points) AS sum (only for clarity when use the sum)

    2. Check that points are numerical fields not varchar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code. This code executes the same sql query twice. Because
I got the following code on my php script: $result = $conect->query(SELECT nome, classificacao
Let's say I have following code cursor = connection.cursor() cursor.execute(query) after that point I
I have the following code factory = new Configuration().Configure().BuildSessionFactory(); session = factory.OpenSession(); var query
When I say simply say select c, the following code works, but I want
With :limit in query, I will get first N records. What is the easiest
I can't display the first entry from my query that returns multiple answers. For
I'm using a TableAdapter for the first time and adding a custom query to
I have the following classes (I've trimmed the code): public class SqlWeightTrackerRepository : IWeightTrackerRepository
I have the following code which uses the WWW::Mechanize and HTML::TableExtract modules. Everything works

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.