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 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

The following code works, but I want the groups to show their latest query
I created the following script to query a table and return the first 30
Ok, I have an example table with the following information and query. First up
I am actually stuck in merging the result of this two queries: first query:
I want use rownum in following query select, i use of it true in
I have the following code to perform a dynamic query of JOINED tables but
I have the following code. This code executes the same sql query twice. Because
I have a following oracle query: SELECT a.USER_ID, c.first_name, c.last_name, TO_CHAR( b.logon_date, 'MM/DD/YYYY HH:MI:SS
I have the following php query... INSERT INTO `demographic2` (id, name, first_name, last_name, link,
Updated question: Django is giving me the following sql query: SELECT auth_user.id, auth_user.username, auth_user.first_name,

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.