Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How Do You Select All Records In The Month You Are In?


I have records in the database - one of the fields is a date field. I want to select all records in the database that are in the month I am in.

For example, if it is the 12th September 2002 today and I go to the page then it selects all records from September 2002. If it is the 4th June it selects all records in June etc.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Selecting Current Month In Month Select Dropdown
I have set up a simple dropdown to list all the months a year from now and for the past year, so form July 2006 - Jun 2008. However, I am looking to have the current month as the selected option when the user first sees the page. Any ideas on how to do this? Code:

Select Using Current Month
I run a website with a news posting part to the site (news from a few members not current affairs). It has occurred to me that the collection of Next & Prev links at the bottom of the viewing page has started to get rather large. This is probably because it generates links for every 4 posts that are in the database (4 articles are shown per page).

What i would ideally like to do is be able to show all posts from the current month in the main page and have an archive page that shows the rest. Now heres the prob that i have run into. I store the date for each of the posts in a datetime field.

When this is selected from the mysql query i format it to make it look like an English time (Rather than the time that the server shows). Now im not too sure what sort of query to use.

How Do You Select All Records After Today?
I want to select records from the database using: PHP Code:

Copy Select Records To New Table
In the table Step I have multiple records for each given id. I want to save the current list of records for an id to a new Step_Old table so I can look back at what I had at a given point in time, since the records for an id in the Step table will change over time.

Now the question... does anyone have a slick way to do this, or do I need to Select all the records I want to save and then save them one by one with a while loop into the Step_Old table?

How To SELECT Records WHERE Field Contains A Particular String?
I need to SELECT records WHERE a string matches the content of a field...

eg. I have field values like:

Phone namePhone name pinkPhone name bluePhone name polka-dot
What I want is to have a MySQL query which selects ALL records which match the search term, eg. 'Phone name' returns all of the above, but not 'Phone':

Currently my query looks like this:
SELECT * FROM [table_name] WHERE [field_name] LIKE '%s' ORDER BY [value] ASC

Very Slow MySQL SELECT Query After 11 Records
I have a very weird problem

I moved my database to new IIS 6.0 + PHP 4.3 + MySQL 4.0 setup. I tried to check with myphpadmin if everything works fine, but I couldn't browse my table (125 records). I used SELECT option and found out that SELECT query up to 11 records is ok, but after that, even if I choose to limit query to 12 records, it just hangs.
I tried selecting from the beginning of the table and from the middle - same thing, but when I run query localy on mysql console, everything works fine

Select Distinct Records Within 2 Separate Tables
I have 2 tables -
1) - paid counties
2) - free counties

and I want to search both to find a distinct list of the counties used. Is there a way to search the first list (save the data into an array), then add ONLY the distinct counties from the free table into the array. Then read all the data out of the array sorted by CountyName,CountyID.

Previous/Next Links As Month Names To Sort Listing By Month
I'm trying to build an event listing and realized that simply having previous and next buttons wasnt the best solution. Rather, I'd like to show the events by month and have the other month's events shown by following a link that would actually be the previous months name and next month name. Code:

Convert Date() Month Numeric Into Month Full Name.
date("m"); returns the following result for this month... "02"

That is fine and dandy, but the problem is, I need to change 02 into February, and not by changing it to date("F"); I need to use the date function to convert the supplied number of 02 into February, is there a way of going about this logically without a bunch of if/else statements??

Month Selection Dependant On Current Month
Basically I'm using a combo box to allow a user to select a month to see accounts stats for that month, so at the moment I am using the script below which will display all months up 1 less month than the current month (as obviously months after this do not have account details yet) However I want to allow the user to have a full 12 months to select from so if the current month was Feb 06 they could see Feb05, march05,April05.... up to Jan06... PHP Code:

Month Number Increases But Month Name Does Not
PHP Code:
for ($thisMonth = (int)$minMonth; $thisMonth <= 12; $thisMonth++) {
$monthName = date('M', strtotime($thisMonth));
print_r("thisMonth = $thisMonth and monthName = $monthName<P>");
}

Quote:
thisMonth = 7 and monthName = Sep

thisMonth = 8 and monthName = Sep

thisMonth = 9 and monthName = Sep

thisMonth = 10 and monthName = Sep

thisMonth = 11 and monthName = Sep

thisMonth = 12 and monthName = Sep

I am at a loss, please help, time sensitive I'm afraid, must be done in
an hour (it's 4pm EST now)

Month And Day Of Month Edit Fields
I wish to have a month select and next to it a day select.

Is there no way at all for the day field to pick up the selected month
without a previous submit on the part of the user?

Displaying Priorty Records And Normal Records In The One Dataset.
I have a page which displays the records from the database and uses paging to display the records in groupes of 10 per page.

I now want to be able to show results depending on the database field (display) in the database (can be set to either "full" or "limited"). If the record and the field display is equal to "full" i want to then display this record at the top of the record set and display all the fields.

If the record is equal to "limited" i want to display different results and they must show after all the records which are equal to "full". I can't output two different recordsets as i use paging and only want to show 10 records per page. Code:

Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution.

So it goes <select name='status[]'>... <select name='resolution[]'>

Then i have a another php page.
$status = $_POST['status'];
$resolution = $_POST['resolution'];

Now my question is, how do i do the sql query statement?

mysql_query("SELECT * from bugs where status=$status and resolution=$resolution");

The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.

SELECT Error: No Database Selectedin Query: SELECT * FROM Schedule
I got the above error message after reading FAQ #10 which applied to my first error. The thing is, I thought I had selected a database. This script is copied from a tutorial, and I'm just too new at this to spot my error. PHP Code:

Get Last Month
How can i know what is the last month..? or even how can i know what is month three months ago..

How Many Day In That Month
Is that any function in php or mysql that we can know how many day in the month?

Getting Age With Month
I need to get accurate age of user with month from date of birth stored in
mysql

date is stored in mysql like this 1983-05-05 and i need to show age like
this 23 year 11 month

I have calculated years but months are not calculating correctly

can anyone give some example how to calculate exact year and month.

Last Day Of Month
I want a function to determine the last day of the month. The function must actually calculate a date minus X amount of months (the months won't be more than 12 months)
I've got the following: PHP Code:

Last Day Of The Month
I am developing a calendar. How can I get the last day of a month.. mean which days is it Sunday, Monday or. it should be in numeric form Like Sunday is 0, Monday is 1... etc.

Getting The Month
Is there a function that gets the numerical value of the month?

Getting Last Day Of Month
I am trying to create a dynamic date that returns the last day for a month, depending on the month. PHP Code:

Getting First Day And Last Day Of Month
Hi, Using PHP 4, if I have a date, what is a function I could use to
give me a date that represents the first day of that month? For
example, if my date were "3/19/2006 8:00", I would want my function to
return "3/1/2006 8:00". Similarly what function would I use to return
the last day of the month? In the above example, the output I would
want returned is "3/31/2006 8:00".

First Day Of The Month
Anyone know how to tell what the first day of the month on (Sunday - Saturday)?

Last Day Of The Month?
Im having to do a bit of string manipulation and with the given values I need help trying to find out the last day of the month...

Im passing the date format of: yyyymm (200706 being this month)(and im unable to change this for several reasons) and Im using substr to find the first 4 chars as the year and the last 2 chars of the month. With these two values I need to find the last day of the month (in this case last day of this month would be 30)

At the end I then do an sql query where timestamp>=yyyy-mm-01 AND timestamp<=yyyy-mm-dd (where dd is the last day of the month value im trying to find.)

Any ideas with the above issue?

Number Into Month With St,nd,rd,th
Is there a shorter faster way to do this...? PHP Code:

Timestamp + Month
I have a Unix timestamp and i want to add 3 months to that time and return the result as a Unix timestamp. How do i do that?

Week Of The Month
I need to determine the week of the month (1-5) so I can rotate menus for a cafeteria.
Is the following, which I know prints the week rather than storing it, the simplest or easiest way to determine the week? PHP Code:

Caluclating Nth Day Of Month
I have a site where a meeting date is posted and that meeting always meets the First Monday of the month. What I am trying to do is calculate if it is the first Monday or not and print something like "The next meeting is Monday, August 7, 2006" and so on for each month of the year. I can do almost anything with phps date functions except that.

Month Difference
I am trying to work out the difference in months between 2 dates.

First Day Of Month From Sql Date.
If I have an sql date, such as "2006-11-19" is there a way using either
sql or php date and time functions to get the date of the the first day
of the month ?

Month Validation By Name
im trying to validate whether or not a proper month name was entered in a form
heres my script (does not work) the variable $birthmonth refers to a month by name, i.e. November, October, etc.

<?php
  if (date("n", $birthmonth) != range(1, 12))
  {
    $errormsg = 'You have specified an invalid month of birth';
  }
?>

Function To Get The First Day Of The Month ?
What function to use to get the first day of the month ?

Report By Month?
how to make report by month? i want to call out from my db but how to make the weekday function and also holiday?

Count The Hits From Different IP Each Month
I have a table (url) which counts the number of hits of my sites for each month. Now I want to know how many hits from each IP address for each month. How should I design the table? I want to design the table (IP)which contains 13 columns, the first one is IP, from the second to thirteenth, each column is for a month from January to December, but it is redundant since the url table already has the month columns. What is the efficient way to design the IP table?

Getting Month And Year From A Date
Using PHP 4, how would i Extract the numeric month and year from a date
variable created using the date() function?

Month From Week Number?
Has anybody here ever made or seen a function which when passed year and week number in that year returns month ?

actually what I want is all records from db starting from six months back till now and group them by weeks, and some weeks may have no record so they won't appear in resultset. But I have to display zero against these weeks.

display has to be in form of Number of Records in Week # x of Month y e.g Number of Records in Week 2 x of Month Jan So my solution is to get records from db by this query:
.. where abs(Week(Now()) - Week(RecTime)) <= 26

this works ok but I don't have any idea of which month and week of month was 6 months ago.
So I decided to get week number and year of 6 months back and then write my function get month form this info.

List The Data By Month
i have done one form where the data will be listed from the database.Now the user asking me to change the data sholud be list by current month. But i was storing the data like 12-4-2007 here can i list by month?

but i know we can do by changing the database but i dont want to change the database its very difficult to change the user database.

Get The Previous Month Date
I have date('F'); for this month but I can't remember how to get the previous month date('F'); - 1

Number Of Days In Month
is the only way to find out  the number of days in a month is using this functions?

cal_days_in_month

Number To Represent It's Month
I was wondering if it were possible to take a number and format it to represent the corresponding month. For example:

Say you have 01 (which we know would be January). How can I format it to be January? I am retrieving months from a datecolumn in a database with the mysql month() function.

I have discovered the mysql monthname() function, however I need to keep the value of the months as a number, so that wont work.

Adding A 0 Before 1,2,3,4 Etc In Month Drop Down
I have the following drop down which is to display 1-12 for months January to December. (It also contains -- which means no month selected.)

However, the months are displayed 1,2,3, 4 etc. How can I get it to be displayed like 01,02,03,04 etc?? I tried using printf but not sure whether Ive put it in the right place? Code:

Sort By Month From Database?
i have a module that sorts all reports by date but it doesn't work i'm not getting any errors.. i'm guessing its my query but i'm not that good in guessing. basically all i want to do is display data depending on what the client is asking..

for example if a client would choose form the dropdown list to display reports in march all reports in march should appear but it doesnt. Code:

Number Of Days In A Month.
How do I get the total number of days in specific month? if I use date("t");

It will get total number in the current month, say I want 1, 2, 3, or even 100 months into the future. how would I do that?

Dynamicaly Display Month And Year
Hi how can i display month and years dynamically without using database in a drop down menu.

<select name=month>
<option value=1>January</option>
<option value=2>February</option>
...
</select>

Also the year drop down since 2003 value will be added with every year ie in 2004 it shd show:

<select name=year>
<option value=2003>2003</option>
<option value=2004>2004</option>
</select>
and so on..

Any help?

Figure How Many Full Weeks Are In A Month
Im trying to figure how many full weeks there are in a month and then
get the third full week dates?

Selecting Year & Month From Timestamp(14)
What I'm trying to do is create a link to a page that displays the headings of articles from a previous month of the year. The link will be something like <a href="/prevnews.php?yearmonth=$var"> and then on the page I will query the database with a line like:

SELECT * FROM table WHERE TimeEntered=$var

My problem is, I don't know how to select all columns from a table where the year and month are whatever I specified in $var. My TimeEntered column is timestamp(14), so YYYYMMDDHHMMSS. If I could just get the YYYYMM part, that would be fine. How do you do that? Also, I run this query on the page. Could I somehow use the variable fDate to get the YYYYMM ? PHP Code:

Date Month Search Queries
I'm putting together a news script and in the news archive, I have a section where you can display the news by the date, or in my case, the month.

I have my news items entered into the database in a MySQL datetime field and the form that you input the date to display in gives back dates like: "January 2001" or "March 2001" though I can change that to whatever, but that's besides the point Once I have this date I use the strtotime($var) function to convert it into a unix timestamp. Here's my query: PHP Code:

How To Generate Month Options In A Menu?
I'm trying to generate options in a menu that read

<option value="2006-03-01 00:00:00.0">March, 2006</option>
<option value="2006-04-01 00:00:00.0">April, 2006</option>
....
<option value="2006-12-01 00:00:00.0">Decmeber, 2007</option>

where the beginning is defined by the month/year of today's date and
the end is defined by a constant "FINAL_YEAR".

How would I generate the above menu using PHP 4?


Copyright © 2005-08 www.BigResource.com, All rights reserved