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




Finding Months With Data


I have a simple 'blog' database table containing content with the posted date entered as date (yyyy-mm-dd).  Some months there will be many items, some months there may be none.

Can I generate a list of months where there is at least one item, without lots of separate queries? If so, how?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Finding A Percentage From Mysql Data
I have information in my database that shows as 50:100 and I want to find the percentage of this number so that I can have the value of 50% show up instead of 50:100.

Finding Double Data In Text File
I am working on this e-mail newsletter subscription thing and I am storing the data in a txt file (mySQL is better, I know but I want it to be compatible with non-mysql systems).

Off course I don't want any e-mail adresses appearing twice in my list (the list looks like this: someone@somewhere.com, blah@bla.com, et cetera). How can I prevent this?

Get "Months Between" Using Only Months And Years
I'm planning a form that takes Work History detail. Of course two of fields in this form are "From" and "To". For this project, the client doesn't need to know the "From" Day, or the "To" Day. He just wants to capture from "2003-07" to "2006-09" for example.

My problem is, without using the entire date string "2003-07-07 / 2006-09-01" how does one go about accurately determining the number of months between the two year/month pairs? Is this possible, or do I have to capture the full date?

Print Last 6 Months
I know you can get the current month using data("m"); How can I output the last 6 months (numeric value "m" and text representation "M") from the current month including the current month. Have tried a few solutions but falling down when current month is for example 2 it should print out:

2- Feb
1 - Jan
12 - Dec
11 - Nov
10 - Oct
9 - Sept

PHP Numbers To Months?
I'm creating a calendar type thing. The variable $month will be a value ranging from 1-12. I need somehow to translate 1, the first month, in january - 2 into february - 3 into march etc.

It auto increases so i cant just change the value to jan, feb. $month has to server two purposes and i dont know how to get it to turn "1" into "january".

Months Dropdown
I'm looking to do a dropdown with the months in the year starting with this month and going on for 12 months, ie. the selected month is April 2007 and the last month is March 2008, does anyone know how to do this using PHP?

Last 3 Months Dropdown
I need to come up with something that will take the current month, for example this month is april.
It would create a drop down list like

Feb 1 - feb 30
march 1 - march 30
April 1 - April 30
Basically the last 3 months, including this one.
Then I am going to need to save the month as the value, so I can pass it to the script so I know what date ranges I am looking for.
I can't think of a logical way to do this, and still account for the fact that some months have 29 days, some have 30, and some have 31.

Months Diference Between Timestamps
How can I get the enlapsed months, complete months between two timestamps (Unix timestamps)? is there any function that'll help me ? or what aproach should I use?

MYSQL - Select XX Months
I have a database set up, with one of the fields is a month -

"200611" = November 2006
"200610" = October 2006
"200609" = September 2006

I was wondering, I know how to sort descending etc.. - Is there a way,
to (add to an existing search criteria).. select all records in the
last XX months..

IE, If I only wanted the last 2 months, it will only select records in
October & November 2006....

or September also - if I want 3 months...

(I have records going back to April 2006)

Im guessing the 'unique' function will be used, but im not sure how to
select XX months.....

Display 11 Consecutive Months
I need to display 11 consecutive months from any given month so something like $current_ month + 11 would give me Nov 2002-Oct 2003. Code:

Number Of Months Between 2 Dates?
i have my dates in timestamp in mysql, please provide code to get the number of months between these 2 days, i've already been searching on the internet for hours.

Storing Months In Mysql 4
I'm using PHP 4 and MySQL 4. I want to store the month and year
as a single row but I am having difficulty figuring out the best data
type to use. I suppose I could use 'DATE' and then always have the day
value be equal fto 1, but I figure there's a more elegant approach. I
leave it to on e of you experts to recommend one.

Drop Down List With Months
I am trying to create a drop down list that has December 2006 as the first option and then goes up month and years till the current month and year (September 2007).

Days Based On Months
I am trying to modify some code so that the days dropdown has the correct amount of days for each month( Jan - 31 days, Feb 28, etc). I managed to get it so the correct days appear however it lists all the days. Code:

List All Months Since YYYY-MM-DD
How can I print in a list format, all the dates since 2006-12-01 up to today, for for example

December 2006
Janurary 2007
February 2007
March 2007
April 2007

and then as we get into a new month, it would be added onto the bottom. I'm sure ive asked this before but I cant seem to find the post or example I saved.

Drop Down List Of Months
I am trying to create a drop down list with 12 months as the contents. I need to be able to determine what the latest month is and then put the 11 months before into it (in the correct order). For example, it is September 2007 obviously at the moment, so that will need to be the last and latest month in the list. The other 11 will be in reverse order going back to August 2006.

Calculate Years And Months Of Service
I have each employees hire date stored in date format in MySQL (YYYY-MM-DD) and would like to calculate how many years and months of service they have.  The output would be like: Years of Service: 7 yr and 2 mo How would I go about doing this calculation?

How Do You Make A Date Change Automatically Every 3 Months Please?
I am making a site with PHP. I have a section of the site where I want to display a piece of text (a date). I want that piece of text to change 4 times a year (every three months).

How do you do this with PHP please?

Calculate Future Months [Reference Correction]
that ref fails for me after being googlegroupbeta'd... hopefully,
try this: http://groups.google.com/groups?th=613f743e0cf622f3

Selecting Rows Between Dates (years And Months)
How do I query the database to select all the data from say, March 2007? There is a "date" column .

How To Populate Selects With Years=>months=>days That Dynamically Change?
What I'm thinking of doing is in my admin page have three different selects. They will form the day of sales at my shop.

-YEAR- -MONTH- -DAY-

The years will have 2002 -> 2005 and the months will be the 12 months of the year of course but I need the number of days to change with the particular month selected.

Finding How Many There Are In A Var
how can I find out how many newlines there are in a variable?
It's not hard to find out if there is a newline in the var, but I wanna know how many!

Finding Id Value
i am using php and mysql for this. i only want to keep the last 5 entries in the database. so i will add an entry in, which will have an ID value, then i want to delete the id with the lowest value, which in turn will be 6 from the last entry added. so the code will look like this:

$oldid = $newid - 6;
$deletethis = mysql_query("delete from table where id = $oldid");

is there a simple way to find the value of $newid ?

Finding Out An IP
I've been wondering for some time now, how to get every visitor's IP address and log them. Any ideas?

Finding @ In String
What's an easy way to tell if a string contains the @ char?

Finding Referer In PHP
I'm trying to determine the location a user has come from when they access a script of mine (a custom web logging script). I've searched the manual for 'referer' but can't find any relevant references and looking at output from phpinfo doesn't shed any light on which, if any, variables might hold info about where the user has come from.

Finding The Sum In Mysql
What would be the easiet way to add the values of a certain field in every record that it occurs in.

For example, If a person is placing multiple orders on a website and each order is to be shipped to a different location. Each seperate order is being stored in the mysql db and I need to add the shipping costs of all orders together when the user is ready to check out.

Finding The Last Occurance
I'm working on a update at my site. Every file on a part of the site
means something. I want to accomplish some kind of a directory
browseing and at each file displays the realtive info in it.
Anyway... The following part of the code is made for finding the last
occurance of '/' and after i did it, it looked kind of 'primitive' to
me :). Is there any other optimised way of finding the last occurance
of a substring in a string ?

Finding MySQL With 5.0.3
I have loaded PHP MySQL and Apache on windows in the past but recently had to reload my Win XP which is SP2 fully updated.

Have reloaded Apache - fine - and MySQL and MySQLAdministrator - working fine

Loaded PHP 5.0.3 and worked through configuring the ini to show a path to the ext file and so forth - copied some of the dll in the apache file.
Copied many of the addtional modules in pecl into the php/ext directory and uncommented lots of them in the php ini (as suggested in a web tutorial - actually I don't NEED all of them yet)

Installed PHPMyAdmin and configured that and then tried to connect but only get the error message that "cant find mysql"

I tried this twice first with MySQLi and then MySQL set in the PHPMyAdmin configuration.

Same result - some advice on a forum to a similar question suggested copying the dll files to the main php directory (just meant moving them up one in fact) and I did but that does not work either

phpinfo shows lots of the modules but not MySQL or MySQLi

I am rather puzzled - can anyone help this (long winded) problem?

Finding The Php.ini File
Is there another way I can find where the php.ini file is located besides using phpinfo();

The one that shows up in that file is not a valid directory--is not reading from the php.ini where I have it stored because the changes I'm making to the ini file are not reflected when I run code.

I can't do anything with session or includes because the I can't get php to read from the ini, or it is reading from another ini file and I don't know how to access it.

DOM Child Finding
Is there any faster/easier way of finding a child node of a certain
DOMNode object than doing something like

function getChildByTagname($curnode, $name)
{
foreach($curnode->childNodes as $node)
{
if($node->nodeName==$name)
{
return $node;
}
}
}

?

it seems fairly slow and cumbersome. i was thinking xpath, but i can
hardly imagine that to be a lot faster, with all the DOMXpath object
creation and all, though I didn't benchmark.

Finding A TAB Character
Does anyone know how to find a TAB character in a string or explode
on TAB into an array?

Finding MAC Address
any body knows how can i find my system mac address using php.

Finding Directory
would like to know if there is a way to locate a specific directory on your site. I have a script which scans a directory, but it is not always running in the same directory, so the relative path to the scanned directory will be changed.

Is there a way to find the location of the directory to be scanned, and build a relative url to it?

Finding H-tags
I am trying to build a script whic will convert html pages, to php, and formatting them to fit the php file's setup... i am trying to also improve navigation - which is where i am stuck.

I need to find all information located between any number of <h2> </h2> tags, and place the contents into an array, which i can then print of, and link to that section i just need to find a method to find the information, and then put it into an array.

Finding Out IP Addresses
is it possible to get the persons IP address so that depending on what IP he has come from, I send him to a different page? any ideas?

Finding Out If PEAR Is Available
I would like to find out whether my Webhoster provides PEAR or not. Is
there a (simple) way to figure that out?

Finding Pagination
First, let me say this is NOT a "How do I paginate my results?" question. I know how that works. Problem: I have items that are listed by date and medium. Both have paginated listings for searching for items. What I need to do is go back to either list to the page where the current item is listed.

Say item #10 is listed on page 1 of dates, and page 5 of mediums [simplified for illustration]. I want the user to be able to come from dates - then move to the mediums listings, while finding the item just viewed on the resulting page.

To determine the mediums listing I tried a function where I looped through a pagination function looking for the $id of the item in the result set with in_array(). It would only return the highest page number, if it returned anything. I have really trashed the function, and have to start from scratch. It seems my logic is wrong. Code:

Finding Out About Html_doc()
I'm trying to get some PHP4 code working on PHP5 - and am having an
issue with a part of the code that uses html_doc() to turn html text
scraped from a website into something that can be processed by DomXml
functions like xpath_eval()

I've found a nice looking wrapper at
http://alexandre.alapetite.net/doc-...mxml-php4-php5/
which seems like it should do PHP4<->PHP5 work, except that it doesnt
support html_doc().

I've tried replacing html_doc() with:
domxml_open_mem($doc,DOMXML_LOAD_RECOVERING)
but I can't get that to work even with the PHP4 - is that down to
validation errors in the HTML?

My problem is that I can't find any documentation to explain what
html_doc() is meant to do and I'm new to the details of domxml coding
(though I know what an XPath is...)

In summary, two questions:
- can I use domxml_open_mem() as a replacement for html_doc() in
PHP4/domxml. If so, how?
- where can I find documentation on html_doc()?

I've googled, searched php.net and looked through group archives and can't
find anything



Error Finding
My current web site appears correct. However, I know some browsers are
smart enough to get around misplaced tags, and other syntax errors.
Does anyone know of a good browser(s) that isn't so forgiving but
still supports server-side html (shtml) and php scripting?
Also, are there any tools out there that identify syntax errors within
html, javascript, php, and or pearl code?




Finding The Mode?
Does anyone know how to write a program to find the mode of a series of numbers? I need to find the mean, median and mode. I was able to find the formula's for the mean and the median. But I have not been able to find a formula to find the mode. I know that the mode will be the numbers that are listed multiple times. I just can not figure out how to write this in the program to echo the mode.

Finding Out IP Address Behind NAT
I am writing a PHP app for a small business (family member owes me
after this...) but they need to get their box back before I am
finished. They have a DSL with dynamic ip and I need to be able to
SSH in to their box, so I need to write a script that i have run as a
cron job that will email me the current public IP of their DSL modem...

PHP Finding Text
i want to create a PHP Script that would go through a list inside a text file and ignore all of one kind of value and print all of another?

e.g.
lets say i had a text file that had in it:

koum
test
test
test
test
koum

i would want it to go through that text file, ignore all of the test's and only print or echo the koum's.

Finding The Browser
What code do i use to find what kind of browser someone is using???

Finding The Mode
Can't figure out how to find the mode of a file (string occurring most often). Has anyone else managed to do it?

Finding A Value Within A String
Say I have a string, for example: "Name: bob, Age: 22".

I know that there is a name stored in there and that it is in that format. How can I trim that string down until it's left with just the name?

Finding Php.ini On My Website?
I'm having trouble finding the php.ini file on my website (It's running a Unix server). I know it's located at /usr/bin/php, but how can I access the /usr/bin/ folder? Do I need shell access? And can that be done through cPanel?

Finding The Date
I need help in finding the date of the 1st day for a specified Week. Lets suppose if I specify the week of the year as 22, I should get the date as 5-28-2007 which is Monday.

Is there any function or can I get a script which gives the above requirement?

Finding Sub Strings
I think i might need to use preg_replace. However I have never used it before and can't workout how to find the following.

This is my string..
Call Out Fee for 10:00 on 20/8/2007

What I need is for this string to be reduced to 10:00 and 20/8/2007. These values would preferably be in an array. Could someone give me a hand with this please.


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