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 6563321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:49:03+00:00 2026-05-25T13:49:03+00:00

i m developing a dynamic website but i have a problem with a query.

  • 0

i m developing a dynamic website but i have a problem with a query. I m trying to build a map dynamically by retrieving date from the database. I enclose the db structure:

countries (code, name)

data (user_id, dateaction, container)

users (user_id, country_code)

I want to display a list of the AVG container for each country, but the average value should be calculated from last action of each user and the data should be submitted the current day. In the case of non-value of “container” for any country the value is 0. I tried many queries but i couldnt achieve the target. I attach some of the queries i tried.

$query = "SELECT AVG(data.container), data.user_id, users.country_code ".
"FROM data, users ".
"WHERE data.user_id = users.user_id AND dateaction >= '".date('Y-m-d').' 00:00:00'."' AND date < '".date('Y-m-d').' 23:59:59'."'".
"GROUP BY users.country_code ";

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){
    $cid=$row['country_code'];
    $queryy=mysql_query("select * FROM Countries WHERE country_code='$cid'") or die("Error Occured,plz try again1");
    $rowy = mysql_fetch_array( $queryy );
    $cname=$rowy['country_name'];
    echo '<area title="'.strtoupper($cname).'" mc_name="'.strtoupper($cid).'"></area>'; }

Please may you help me to solve this logical problem?

  • 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-25T13:49:03+00:00Added an answer on May 25, 2026 at 1:49 pm
    $query = "SELECT a.user_id, ifnull(a.country_code, 0) as country_code, avg(a.container) ".
    "FROM data a INNER JOIN ".
    "(SELECT data.user_id, max(dateaction) dateaction ".
    "FROM data".
    "WHERE dateaction >= '".date('Y-m-d').' 00:00:00'."' AND date < '".date('Y-m-d').' 23:59:59'."'".
    "GROUP BY data.user_id) b ".
    "ON a.user_id = b.user_id and a.date_action = b.date_action ".
    "GROUP BY a.user_id, ifnull(a.country_code, 0) "
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very dynamic SQL Server problem to solve. I am developing a
I'm developing a dynamic website using jQuery and I have found several jQuery plugins
I'm developing a web service whose methods will be called from a dynamic banner
Developing a website and just trying to get back into the swing of (clever)
I have dynamic grid-based tables in the application I am developing. The following code
I am developing pages in php dynamically i.e data gets filled up from mysql
I am currently developing a C# .net xna game engine. I have been trying
I am developing a dynamic web project j2ee web application using eclipse. I have
I am developing a simple website with few JSP pages. Each jsp does have
I'm developing a dynamic website using JSP & Spring MVC 3.0 and I can't

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.