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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:36:34+00:00 2026-05-15T03:36:34+00:00

I have loaded an associative array of records from a MySQL database table. The

  • 0

I have loaded an associative array of records from a MySQL database table.

The array consists of 1 to 7 rows representing one week of entries,
which might not have been entered for each day.

How can I insert blank rows into the array for the missing days
so that I can easily display the data in a table?

I don’t need to update the database with the blanks.

Example:

             Field1  Field2  Field3  Field4 .... Field#  
Record[0]
Record[1]
Record[2]
Record[3]
Record[4]
Record[5]
Record[6]

Field4 is the date as yyyy-mm-dd

I load the array automatically using a start date and end date

Some weeks there will be a Sun, Tue, and Fri or Mon, Tue, Wed, Fri & Sat.

  • 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-15T03:36:34+00:00Added an answer on May 15, 2026 at 3:36 am

    this is simple:
    Do you know how many “Fields” you have for each day? let’s say it’s “num of fields”

    $records = array_fill(0, 7, array_fill(0, <num of fields>, ''));
    

    what this does is it creates a blank array from [0] to [6] and for each array element it inserts another array of “Fields”, with “num of fields”, each of which is set to an empty string ''.

    Now that you have this, you read your data from the mysql table and if you selectively assign $records by index (i’m assuming), the rest of them will stay blank.

    Keep in mind that you can reassign an element of $records array by using something like

    $records[5] = array('New value', 'Field2 value');
    

    which is what you do when you read data from mysql table.

    Do you use some kind of index in your mysql table to correspond to the numbered day in a week?

    comment here if you get stuck with mysql part.

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

Sidebar

Related Questions

I have loaded my database with one table under Data Connections in the Server
I have loaded an byte array image from a web service to my asp.net
I have 2 sections within a table view and I have loaded one section
I have loaded an array wih data out of an xml file. I know
I have a table with 6400 rows. This is a parent-children table, it has
i have loaded a file into an array using ajax and after splitting it
I have in my mapping an association to an eagerly loaded collection (lazy=false fetch=subselect).
I have loaded the calendar in my LWUIT based UI. Thanks to this thread
I have loaded an xmi file with an uml diagram. As a result I
I have loaded an XML file using simplexml_load_file($filePath,'SimpleXMLElement', LIBXML_NOCDATA); And for most of the

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.