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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:51:44+00:00 2026-06-03T09:51:44+00:00

Not sure how to name correctly this question so feel free to edit if

  • 0

Not sure how to name correctly this question so feel free to edit if is needed.

I have 12 boxes one per month, and each box display:
1 – A message like “Sold” or “Available” depending on the info coming from the database.
2 – The name of the month and the year, if the month is older than the current month the year will be increased by one.

The info coming from the database have a few values separated by a | symbol, the pertinent one to check is the las one, an example value of $row[‘custom’] is: 93 | Supper | New Port | August – 2012

My problem is that I need to update each box with their “status” and with the current script only the las entry on the database is used to update the boxes, so In cases where i know there is two or more boxes that should display the message “Sold”, only the most recent is the updated.

How can I modify the following script to update one by one box ?
The problem is the way I’m querying the database or something else ?

Thanks in advance for any help or advice.

Code only for 2 of 12 month, to make things short

<?php
$month = date("m"); // Current month
$year = date("Y"); // Current year
$next = strtotime(date("d-m-Y", strtotime($now)) . "+1 year");
$nextyear = date("Y", $next); // Next year

// Check if this month is gone or not, if gone replace current year with next year
$january = "01";
$february = "02";

if ($month > $january) { 
  $jan = 'January - ' . $nextyear; } else { $jan = 'January - ' . $year;}

if ($month > $february) { 
  $feb = 'February - ' . $nextyear; } else { $feb = 'January - ' . $year;}

//Get info from Database

$query = "SELECT `custom` FROM `payments` WHERE `status` = 'Pending' OR `status` = 'Completed'"; 
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
  $check_custom = explode(" | ", $row['custom']);
  $month_sold = $check_custom[3];
}

// Check if month is sold or not
if ($month_sold == $jan) { $jan_status = 'Sold';} else { $jan_status = 'Available';}
if ($month_sold == $feb) { $feb_status = 'Sold';} else { $feb_status = 'Available';}

//Output the months and their status
?>

<div class="month">
  <div class="mname"><?php echo $jan;?></div>
  <div class="<?php echo $jan_status;?>">
    <?php echo $jan_status;?>
  </div>
  <?php if($jan_status == 'Available') { 
      echo 'This month is ' . $jan_status . '.';
    } else { 
      echo 'This month has been ' . $jan_status . '.';} ?>
</div>

<div class="month">
  <div class="mname"><?php echo $feb;?></div>
  <div class="<?php echo $feb_status;?>">
    <?php echo $feb_status;?>
  </div>
  <?php if($feb_status == 'Available') { 
      echo 'This month is ' . $feb_status . '.';
    } else { 
      echo 'This month has been ' . $feb_status . '.';} ?>
</div>
  • 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-06-03T09:51:46+00:00Added an answer on June 3, 2026 at 9:51 am

    You misplaced the closing bracket of while and move the `$jan_status=’Available’ from inside while loop to just above it; Here is the modified code

        <?php
        $month = date("m"); // Current month
        $year = date("Y"); // Current year
        $next = strtotime(date("d-m-Y", strtotime($now)) . "+1 year");
        $nextyear = date("Y", $next); // Next year
    
        // Check if this month is gone or not, if gone replace current year with next year
        $january = "01";
        $february = "02";
    
        if ($month > $january) { 
          $jan = 'January - ' . $nextyear; } else { $jan = 'January - ' . $year;}
    
        if ($month > $february) { 
          $feb = 'February - ' . $nextyear; } else { $feb = 'January - ' . $year;}
    
        //Get info from Database
    
        $query = "SELECT `custom` FROM `payments` WHERE `status` = 'Pending' OR `status` = 'Completed'"; 
        $result = mysql_query($query) or die(mysql_error());
    $jan_status = 'Available';
    $feb_status = 'Available';
        while($row = mysql_fetch_array($result)) {
          $check_custom = explode(" | ", $row['custom']);
          $month_sold = $check_custom[3];
    
    
        // Check if month is sold or not
        if ($month_sold == $jan) { $jan_status = 'Sold';} 
        if ($month_sold == $feb) { $feb_status = 'Sold';}
        }//th closing bracket should be here;
        //Output the months and their status
        ?>
    
        <div class="month">
          <div class="mname"><?php echo $jan;?></div>
          <div class="<?php echo $jan_status;?>">
            <?php echo $jan_status;?>
          </div>
          <?php if($jan_status == 'Available') { 
              echo 'This month is ' . $jan_status . '.';
            } else { 
              echo 'This month has been ' . $jan_status . '.';} ?>
        </div>
    
        <div class="month">
          <div class="mname"><?php echo $feb;?></div>
          <div class="<?php echo $feb_status;?>">
            <?php echo $feb_status;?>
          </div>
          <?php if($feb_status == 'Available') { 
              echo 'This month is ' . $feb_status . '.';
            } else { 
              echo 'This month has been ' . $feb_status . '.';} ?>
        </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not quite sure how to correctly put this question. I want to dynamically
I am not sure if I have asked the question correctly. Please correct me
I'm not sure if I created this topic correctly, but basically I have a
I'm not sure how to state this question correctly, but I am trying to
Note: I am not exactly sure what to name the question, so if someone
Not sure if this is possible or if I'm expressing correctly what I'm looking
I'm not sure if this is a duplicate but if it is please feel
I know what i want but not sure of the name and required tools
I'm trying to follow table and class name conventions, but I am not sure
Not sure if i'm naming it correctly (i.e. nested interface implementations). However I do

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.