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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:17:16+00:00 2026-06-02T16:17:16+00:00

I have form with 4 fields namely(start month, start year, end month, end year)

  • 0

I have form with 4 fields namely(start month, start year, end month, end year)
and MySQL table structure is like id, customer id, amount, month, year

Now, I need to display the rows with matching condition as between the start month and year and end month and year.

I tried this query

select id,customer id,concat(month,'-',year) as d1 from payroll where
empid='$_POST[emp_id]' and (STR_TO_DATE(d1,'%m-%Y') between
STR_TO_DATE('$_POST[fmonth]-$_POST[fyear]','%m-%Y') and
STR_TO_DATE('$_POST[tmonth]-$_POST[tyear]','%m-%Y'))

Please advise….

  • 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-02T16:17:17+00:00Added an answer on June 2, 2026 at 4:17 pm

    Assuming the columns year and month and the 4 form fields are integers, this would work:

    SELECT id
         , customer id
         , CONCAT(month, '-', year) AS d1 
    FROM payroll 
    WHERE empid = '$_POST[emp_id]' 
      AND (year, month) >= ( '$_POST[fyear]', '$_POST[fmonth]' ) 
      AND (year, month) <= ( '$_POST[tmonth]', '$_POST[tyear]' )
    

    You should probably take care of those $_POST[] before sending them to the database for security reasons (SQL injection).

    A compound index on (empid, year, month) would help performance.

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

Sidebar

Related Questions

I have a form with the fields inside table cells. On the last column
I have form, where some fields are looks like rows, so I can add/delete
I have a table body that grabs it's rows (and form fields) via AJAX
I have these form fields with names like this: /dwint/singlepagecheckout/DWINTOneClickCheckoutFormHandler.bean.shippingAddress.firstName Which Im trying to
I had developed one website purely in HTML .I have my form with fields
I have a form with multiple fields that I'm validating (some with methods added
I have a HTML form with fields such as name, address, notes, etc. I
I have a form with 3 fields (simplyfied example). The first one is a
I have a form with input fields and a button which fades in when
I have an application that uses itextsharp to fill PDF form fields. I got

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.