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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:44:28+00:00 2026-05-24T12:44:28+00:00

My query returns two days, say the 10th and the 11th, both just integers.

  • 0

My query returns two days, say the 10th and the 11th, both just integers. I want to create an array for August with 31 rows, with blank data on days that do not exist in the database, and only data for the 10th and 11th. If I do something like:

$daysinmonth = array( "January"=>31, "February"=>29, "March"=>31, "April"=>30, "May"=>31, "June"=>30, "July"=>31, "August"=>31, "September"=>30, "October"=>31, "November"=>30, "December"=>31 );

$days = $daysinmonth[$month] - 1;

$i=0;
echo $numB;
while ($i<$days) {
 $a = $i + 1;
 $day = mysql_query($resultB,$i,"day"); 
 if ( $a==$day ) { 
  $date[$i] = $a;
  $movies[$i] = mysql_result($resultB,$i,"movies");
  $shows[$i] = mysql_result($resultB,$i,"shows");
  $music[$i] = mysql_result($resultB,$i,"music"); }
 else { $date[$i] = $a;
  $movies[$i] = "";
  $shows[$i] = "";
  $music[$i] = ""; } $i++; }

Which throws a MySQL error, of course, because there are only two rows of data. I don’t even know what to ask because I don’t understand most of anything.

  • 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-24T12:44:31+00:00Added an answer on May 24, 2026 at 12:44 pm
    //select the data from your table
    $sql = "SELECT day, movies, shows, music FROM something WHERE something";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_assoc($result)) {
      //put it in an array keyed by the date
      $data[$row['day']] = $row;
    }
    
    //calculate the first and last day of the month's timestamps
    $first_day_of_this_month = mktime(0, 0, 0, date('m'), 1, date('Y'));
    $last_day_of_this_month = mktime(0, 0, 0, date('m') + 1, 0, date('Y'));
    
    //loop over every day of this month
    for ($i = $first_day_of_this_month; $i <= $last_day_of_this_month; $i = strtotime('+1 day', $i)) {
      $date = date('Y-m-d', $i);
      echo 'Date ' . $date . ':';
      if (isset($data[$date])) { //a row existed for this date
        echo $data[$date]['movies'] . ' movies, ' . $data[$date]['shows'] . ' shows,' . $data[$date]['music'] . ' music';
      }
      echo '<br />';
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an sql query that returns rows from two tables with same column
I want to write a LINQ query which returns two streams of objects. In
The below query returns me two rows: SELECT DocList.DocListId, RegistrationDocList.RegistrationDocListId, Registration.RegistrationId FROM DocList INNER
I'm running a SQL query that returns two columns and X number of rows.
This Query returns left outer join from two tables. var q = from adu
What I have : A C# database query that returns two columns, one of
Ok, I’ve spent two days on this and am losing confidence in both myself
I have a SQL query that returns two columns - Title and Count. When
I just want to List the posts published between two particular dates I found
Why the two query below return duplicate member_id and not the third? I need

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.