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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:47:42+00:00 2026-05-16T14:47:42+00:00

I want in a table called week_year with following schema: Week_year = {id, week,

  • 0

I want in a table called week_year with following schema:

Week_year = {id, week, year}

To insert the weeks for each year, such that, for 2001 there is week 1, week 2, week 3, … , week 52, and then start over for year 2002 up until the year 2009.

I’ve tried different PHP scripts but can’t seem to be getting it right. I’ve tried different tables, one for year and one for week and then give each week a year_id, but that didn’t seem to be effective.

I’m hoping that someone can help me create, what I believe is a simple PHP loop(s) to generate these numbers and insert them into my MySQL database.

Added additional Information posted as an answer

I’ve tried this code, which is a endless loop of the year:

<?php

$year = 2001;
$week_start = 1;
$week_end = 52;

for ( $week_start = 1; $week_start <= 52; $week_start++ ) {

echo $week_start;
echo "<br />";
    for ($week_start = 1; $week_start <= 52; $year++) {
        echo $year;
        echo "<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-16T14:47:43+00:00Added an answer on May 16, 2026 at 2:47 pm

    Do this in SQL, not PHP:

    create table artificial_range( int id not null auto_increment, ci int);
    
    insert into artificial_range(c1) values (1);
    

    — NOW DOUBLE THE SIZE OF artificial_range

    insert into artificial_range(c1) select c1 from artificial_range;
    

    — repeat the above insert five more times;
    — you now have 64 rows in artificial_range

    -- now insert into week_year:
    insert into week_year(week, year)
    select a.id, b.id + 2000
    from 
      artificial_range a,
      artificial_range b 
    where a.id < 53 and b.id < 10;
    
    
    -- or even better, just make week_year a view:
    create view week_year as
    select a.id as week, b.id + 2000 as year
    from 
      artificial_range a,
      artificial_range b 
    where a.id < 53 and b.id < 10;
    

    One caveat: depending on what you mean by ‘week’, some years have 53 weeks.

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

Sidebar

Related Questions

I want to make a table in SqlServer that will add, on insert, a
I have one table, t1, which has fileds called userid, week and year fields.
I have a numerical field called category_id in my table. I want to do
I want to make a table that simply has two integer columns to serve
I have a table of data that gets update once a week. I then
I have a SQL table called StudentMarks.which consist of StudentID,SubjectName,SubjectMark I want to write
I have a table called Users it contain some fields such as Id, ParentId,
I have the following table called [Store_Sales] - Store Date Sales 1 23/04 10000
I have a repeater control outputting some HTML. I want a table which outputs
In a table I want to combine some of the columns, but not in

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.