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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:37:22+00:00 2026-05-29T03:37:22+00:00

Right, so i’m still getting my head around prepared statements and every time i

  • 0

Right, so i’m still getting my head around prepared statements and every time i think, yeah i’ve got it, a new query comes along and i’m thinking Hmmmm i would i set that up?

So here we go, i have a query that pulls records from a database based on a date and orders them by said date. The records it finds are based on a year and month value and the query looks like this:

$getresults = mysql_query(" SELECT * FROM `results` WHERE `date` LIKE '2012-$monthid%' ORDER BY date ");

I already have basic prepared statement for getting a users record from my database:

$query = "SELECT *
            FROM results
            WHERE date = ?
            LIMIT 1";

    if($stmt = $this->conn->prepare($query)) 
    {
        $stmt->bind_param('s', $date);
        $stmt->execute();

        if($stmt->fetch()) 
        {
            $stmt->close();
            return true;
        }
        else
            return false;
    }

How would i change this to make it more like the first query?

Thanks for the help.

  • 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-29T03:37:23+00:00Added an answer on May 29, 2026 at 3:37 am

    One idea would be to filter by year and month in separate parts of the WHERE clause:

    $query = "SELECT * FROM results WHERE YEAR(date) = 2012 AND MONTH(date) = ? ORDER BY date";
    
    if ($stmt = $this->conn->prepare($query)) {
        $stmt->bind_param('i', $monthid);
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right, i'm new to PHP and mySQL, but i've got a few questions that
Right now when I run this it keeps clicking on the same button every
Right guys, seeing as you were so helpful last time with my previous question
Right, I've got a slight problem here, in which I've attempted to implement a
Right now I have the following query: User.find(:all, :conditions => [guest = ? AND
Right now I'm using the following command to compile a coffeescript file each time
Right now I'm using OleDbDataAdapter objDataReader = new OleDbDataAdapter(); objDataReader.SelectCommand = myCommand; objDataReader.Fill(myDataTable); But
Right now, to be sure I am getting what I want I am using
Right now I have two tables for getting a timeline of posts that a
Right now, I do this: try: blah except Exception, e: print e time.sleep(9999) Instead

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.