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




Day Of Year Count


I have a script that reports that day on which a post expires as: 2000-06-12. What i would like to do is post it instead as: Expires in: 11 Days. So basically, I'm looking for a PHP3 way to do a Day of year Subtraction. I know with MySQL its:

(TO_DAYS(Expires) - TO_DAYS(Current_Date))

is there a way to do it without going back into MySQL, using PHP3? OR how to i configure my Select so that it will automatically output "Expires" date as a the day count UNTIL expires.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Check Week Number In End Of Year And Begiining Of New Year?
I am creating a little own calendar. Now I want to add a "previous week" and "next week" functionality to the calendar.

It is easy to take $thisWeek - 1; and $thisWeek + 1;, but there has to be a check wether it is the last week of the year and it should actually be a new year and head to week number 1. HOW do I make this kind of function? I use the following string names:

$thisYear
$thisWeek

Starting A Year Loop With Last Year
I have the following which loops through the present year and adds two more years on: However, I want it to be exactly the same but to start from last year rather than this year. Is this possible? Code:

Week Of Year
Is there a function which returns the week of the year, given a specific date?

Last Day Of Year Date Bug?
Guys, the line below just returned "Dec 07" as the date for one month
back from today. Hardly life-threatening, but any thoughts?
<?php print date("M `y", mktime(0, 0, 0, date("m")-1, date("d"),
date("Y")));?>

AS...

Leap Year Calculation
how can i incorporate leap year also at my below codes PHP Code:

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?

Need Date For Every Monday Of Year
Is there a way to get the date for every Monday for a particular year and have it populate a drop-down box? Need something to start by.

Calendar Displaying A Whole Year?
I'm reasonably new to php and have been looking everywhere for tutorials on creating calendars. I've found so many, but they're all relatively the same, where they only display one month at a time. If anyone could point me in the direction off a tutorial where I can create a calendar to display a whole year in one go, instead of one month that would be absolutely great.

I'd quite like a tutorial instead of a simple download, because I can learn more by going through it all. I don't need any fancy stuff like events. It's litterally just a calandar with nothing on it but the dates.

Date() With Leap Year
I am using this function below in a script to create a count down script.

<? date(("z"), time() - (14400 * 1)) ?> My question is; does the "z" (0 - 365) go up to a maxium of 366 when it is leap year?

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?

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:

Populating A Drop Down List With The Year
i'm trying to loop the years from 1960 - 2010 with the function get_year() below:
PHP Code:

Can't Get Month Year From Variable Using Date()
I have a very simple question about date(). I am using date('l, F d, Y'); to show Tuesday, August 22, 2006. But now when I am trying to display just Month - Year i.e (August - 2006) from variable, Its not coming through and displaying January - 1970.

Code: I have done date("F - Y", $entry_date) for this. Can any one just point me out or suggest where I am wrong here?

Exclusive REQ: PHP Developer In Sunnyvale, CA - 1 Year
We have an exclusive requirement for PHP Developer in Sunnyvale, CA. I
can get the interview with in 1 hour and PO by end of the day. There is
no client interview for this position. Please forward updated resumes
with contact info, expecting rate ASAP.

Interview in 1 hour, PO by end of the day

Location: Sunnyvale, CA
Duration: 12 Months
Start: Tomorrow
No of needs: 5
Rate: $Open/Hr
Client: Yahoo

Required Skills:
·3+ years of PHP Development experience
·UNIX or LINUX, My SQL, Apache, Java Script
·HTML, DHTML, CCS
·Web Applications experience is a plus
·Candidates, who have worked with search engines like Google, Yahoo
will be of great help, though it is not mandatory
·Should have excellent communication skills

Printing Full Year Calendar?
I use a calendar script, Keith Deven's PHP Calendar. I've modified it to incorporate events into it and everything works great. The problem I'm having trouble with is when I print the year long calendar. For some reason it only reads the dates in the database for the current month, in this case March and it outputs the same days for every single month. Code:

Search Data Between Two Specific Year?
I have tabel called "candidate" in that i have two fields call Graduation Passing year and Post Graduation Passing year. In that table i have more than thousands number of candidate. Here i want to make a search php form. Where i can get data of specific candidate who pass between specific year.

I have make a form for search with below fields: Graduation Candidate search : Year From and Year To fields and submit button to call query form and display result. Code:

Converting MySQL Date To PHP Day Of The Year
i was wondering if anyone knew if there was a way to convert a MySQL Date (yyyy-mm-dd) to a PHP day of the year

date(z);

as in like January the first would be day 1 (or 0 )

Date/Time Column, Accessing Only Year
I'm trying to generate a table that gives some statistics. I've got a date time
column that registers hits. I need to calculate the number of hits for 2006 using the 'date' column, which is the date time column.

Select Distinct Year From Unix Timestamp
I'm trying to select all distinct years from a unixtimestamp field in
MySQL database. I have a query:

SELECT DISTINCT YEAR(date_field) As theYear FROM table

but it gives me an empty array. What am I doing wrong?

List Weeks Of Year Using Calendar Function
I've been asked to design a small site which contains a page with a list of dates to show a visitor if accommodation (running from Saturday - Friday) is booked or available. Something like this:

2007
2nd Jan - 8th Jan  -  Available
9th Jan - 15th Jan  -  Available
16th Jan - 22nd Jan  -  Booked
23rd Jan - 29th Jan  -  Available
5th Feb - 11th Feb  -  Available
12th Feb - 17th Feb  -  Available
etc, etc

I'd like to dynamically create the list of dates using the php calendar functions and a mysql database so that each row (52 in total?) could be flagged 'booked' or 'available' allowing easy updating using a back end form. Ideally the page showing the list would have a link taking the visitor to another page showing the following year's dates. Each list would always show a year to view and always run from Jan to Dec.

Joomla :- RSGallery Problem :- How To Add Parameters For Images (like Price , Year Etc)
I am using RS Gallery.I want to give/add  different parameters to each image (like price , year etc). Is there any way to do this? If yes Please send me the solution.

Convert From 4-digit To 2-digit Year
I am trying to convert from a 4-digit to a 2-digit year.  Here is my code:

$date = "2007-10-02";
$explode_date = explode("-", $date);
echo $new_date = $explode_date[1].$explode_date[2].$explode_date[0];

The result is 10022007 but I need it to be 100207(mmddyy).

Count()
I am getting an error message if I add another field in the Select statement beside Count().

Count Down
I want to display a countdown timer. For this i used frames, the
top frame contains the time and the bottom frame contains the
questions, the top frame refreshes (autorefresh every second), After
reaching the target time, a new page has to be loaded (redirect to a
new page, which contains the message test time is over). How to do
this? The below code is not redirecting to the timeover page

frame.php ....

How To Count Age?
How can I count the difference between two dates? ( I can't change
them into Unix format using mktime(), because in my database are also
people born before 1970). Are there any alternative functions?

Count & Max
I need to count the rows in a mysql table and to find the max value of a column. I
am selecting count and max with mysql queries, but fail getting the results from my php code. For counting the rows I also tried mysql_fetch_array and then counting the rows in the array, but it didn't work either. Does someone know how to retreive the results of count() and max()?

PHP COUNT( )
the code pasted below works perfectly... however if i attempt to change the select to COUNT(id) and also change the echo line down below, I get errors ... Any ideas about how to modify the code for it to perform the count() function properly? Code:

Count Down
I want to display countdown timer in H:m:s format. for this i am
using frames, top frame contains the timer, (autorefresh and the time
is updated), in the bellow frame, test qustions are there. On
reaching the target time, i want to redirect the whole page to a new
page or (which contains the message the time is over). How to do this?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-
1">
</head>
<frameset rows="80,*" frameborder="NO" border="0" framespacing="0">
<frame src="head.php" name="topFrame" scrolling="NO" noresize >
<frame src="body.php" name="mainFrame">
</frameset>
<noframes><body>
</body></noframes>
</html>
?>
...........

Count
how to count the same data in field?

How To Count Max In SQL?
Maybe this isn't the most apropriate place to ask mysql related
question, but I think it is close enought to most php users and I always
got find answers on this group.

well, I need to count how meny rows have some maximum number. here is
exact situation (striped down table) (pictID, jpeg name, #of votes)

pict1, name1.jpg, 4
pict2, name2.jpg, 22
pict3, name3.jpg, 5
....
pict7, name7.jpg, 8
pict8, name8.jpg, 22
pict9, name9.jpg, 9

so, I need query (or set of querys) which will give me back rows 2 and 8
(I know, rows 1 and 7, but for easyer description, please let forget for
moment that first is 0)

I know what to do if I have only one picture with maximum votes:
SELECT * FROM picts ORDER BY votes DESC LIMIT 1
(maybe not the best solution, but is working).

now, I wanted to count how meny rows have MAX of votes, but I was unable
to do that with my knowlage...
SELECT max(votes)...
and than
$TotalMax=mysql_num_rows($result);
in any combination (list), (while(list(too(much...) only failures...

at the end I wanted to do SELECT with LIMIT so I can drow only those
wining pictures:

$query1 = "THAT one I don't KNOW";
$result1 = mysql_query ($query1) or die ("Query failed...");
list($new_limit) = mysql_num_rows($result1);

//and now:

$query2 = "SELECT * FROM picts ORDER BY votes DESC LIMIT $new_limit";
$result2 = mysql_query ($query2) or die ("Query failed...");
list($pict_data1,$pict_data2,$pict_data3) = mysql_fetch_array($result2);

can anyone help me with that 1st query?
or anyone have easyer solution?

oh yes, I can not tell how meny pictures will have maximum number of
votes. so far (in 4 years of manual handling of my site) there vere only
3 moments with 2 pictures sharing wining position, never more... normaly
just one.

Count Down
I want to display a countdown timer. For this i used frames, the
top frame contains the time and the bottom frame contains the
questions, the top frame refreshes (autorefresh every second), After
reaching the target time, a new page has to be loaded (redirect to a
new page, which contains the message test time is over). How to do
this? The below code is not redirecting to the timeover page

frame.php ....

Best Way To Count
I have a "views" field in my table for each record. Looks something like this:

ID | Views
-------------
1  |  20
2  |  50
3  |  30

What is the best way to display: "Total Views: 100"

Count
I have a database of images each which gets it own number of hits.
how do i then 'add ' all these hits together to get a total number of hits?

SELECT *, COUNT(hits) FROM photos GROUP BY hits DESC LIMIT 5

is my attempt but i know its wrong

Mysql_num_rows() Vs. COUNT()
Does anyone know what is more efficient to count row numbers with?
the mysql_num_rows() function on a query result or using the COUNT() function within a query. Anyone know?

SUM() And Count Problems
I'm having problems using sum() and count.

I want to automatically display the top 10 photographers on my site and I want to sort them by total picture counts and picture hits.

The code below will pick out 10 photographers and display their total pictures and total picture hits correctly but I can't get it to sort by picture counts or hits, the results are sorted alphabetically.

How can I get the code below to sort by total pictures or total hits?

Help With Select Count In PHP
I'm trying to do a script that tells me how many orders I got in on a particular day. The script loads, but nothing shows up.

Any help would be greatly appreciated!

Here it is:

<?
//create connection
$connection = mysql_connect (localhost, xxxxxx, xxxx) or die ("Couldn't connect to server.");
// select database
// substitute your own database name
$db = mysql_select_db (MyDB, $connection) or die ("Couldn't select database.");
$date = "02/05/02";
// create SQL statement
$sql = "SELECT COUNT(*) FROM CUSTOMER as mycount WHERE CREATED='$date' AND STATUS=&#390;'";
// execute SQL query and get result
$sql_result = mysql_query($sql,$connection) or die ("Couldn't execute query.");
//start results formatting
echo "<br><br><div align=center>";
echo "<table cellpadding=5 cellspacing=0 width=&#3995;%'>";
echo "<tr bgcolor='#336699'>
<td width=100% valign=top><font face='verdana,arial,helvetica' size='-2' color='#ffffff'><b>Orders Today:</b></font></td>
</tr>";
// format results by row
while ($row = mysql_fetch_array($sql_result)) {
$mycount = $row["mycount"];
echo "<tr>
<td width=100% valign=top><font face='verdana,arial,helvetica' size='-2' color='#000000'>$mycount</font></td>
</tr>";
}
echo "</table>";
echo "</div>";
/free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>

Multiple Count()
I was wondering what the most efficient way to perform multiple count queries is? Is there any tips you can give that will speed up the process? For instance, is is quicker to do count(*) or is it quicker to count a field that has the smallest amount of info?

At the moment I am using a function to count 26 times, but it has slowed down the web page too much.

What I need to count, is how many records there are for each letter of the alphabet.

Help With Mysql Count(*)
I've been tearing out my hair trying to get my latest project online. I have a user based site and some of the info is being stored in a mysql table where each record is identified by the user's username. I want to generate a list to be displayed online that shows the top ten users who have the most records. Basically just a list of the the most frequently occuring records in the table. Right now I am using the following SQL query:

$sql = "SELECT user, COUNT(*) as number FROM tablename GROUP BY user ORDER by number desc LIMIT 10";

$result = @mysql_query($sql, $connection) or die("Couldn't Execute Query");

I'm getting data back but am not sure if it is correct or exactly how to display it on the page. I typically use:

while ($row = mysql_fetch_array($result)) {}

but am not sure how to extract the count for each record using this.

Count Session?
Is there a way to count the number of active sessions on a server? it would be nice to have something like: "Right now there are $sessioncount visitors in thís site"

PhP MySQL COUNT()
I just can't seem to find any reference of a query string, using two count statements. Any help would be appreciated.

I need to count the records that have a good email and at the same time count the same records that have a bad email.

Then display that result in table form, Grouped by com,net,org etc.

I can get good or bad emails based on the query below but not both at the same time:

Character Count
i need to know how to count the number of characters in a variable. E.g.

$a = "hello";

i want something to tell me how many letters are in $a.

Count Down To Date.
I have been working for the past few months on an AOL instant messenger profile enhancement website, similar to sub profile. I am almost completely done working on a photo gallery which I've done with help from posts on this board and others. But i searched and searched and could find nothing specific to my question.

How do I make a countdown script? So say I have a profile on my website, and I want to show a countdown to my birthday. I enter the date in the member's area to when i want to count down to, we'll say my birthday for example (august 4th) Then when someone views my profile, they see this:

Bouley86's Birthday: XX Months and XX Days

What kind of information would I have to collect and insert into my DB in order for this to work and what would I compare it to in order to get the numbers and how would I have to compare it.

Word Count
I have a form which users can write a letter and outputs it as $letter - done this, but I need something to count the number of words written.

Count Array?
I wrote a counter script which counts each unique visitor,
and counts how often a visitor has visited. The data
is stored in a "counter.txt" file divided by "||".

The lines in the file are constructed as follows:

linenumber||ip-address||times-visited||

e.g.

....
43||34.913.657.901||53||
44||436.422.67.78||5||
45||346.465.3.436||27||
....

I count unique visitors by counting the number of lines,
but how can i count the total of hits?
So that means adding up the 3rd part of each line...
(I've searched php.net, and tried some of the array functions
but i can't figure it out.)

MySql Count
$arr = array ("A", "B", "C", "D", "E");
foreach ($arr as $client) {
$count = mysql_query('SELECT COUNT(*) from table where columnA =
$client');
echo "$client has $count";
echo '<br>'
}

Using Mysql Count
I have the following query that works in mysql:

select id, order_no, price, count(item_no), sum(price) from production
WHERE item_no = ?'
group by item_no;

When I setup my query in php, I use:

$query2 = "SELECT id, order_no, price, count(item_no) as count from
production where item_no = ?";

I keep getting an error in on my php page:

Warning: mysqli_error() expects exactly 1 parameter, 0 given in
c:Inetpubwwwrootproductionproduction_line_dail y.php on line 24
Error in query: SELECT id, order_no, price, count(item_no) as count from
production where item_no = ?'.

If I remove the count(item_no) as count from the query - it works fine. I
really want to put the count in though. And eventually the sum.

Count Of Checkboxes (again)
I'm still stuck with this problem. Here's a quick recap/summary :-

1. Page 1:User checks 3 out of 10 checkboxes and submits form to page 2
2. Page 2:Item count shows 3 items. User checks an additional 2
checkboxes and presses Update button. Item count now shows 5 checkboxes
are checked and "New" checkboxes remain checked.
3. Page 2:User is happy and submits form to page 3
4. Page 3:Form items are converted into printable text/data

Pedro Graca very kindly offered a solution using "header('Location:
<URL>')" which very nearly worked however my problem is that the form
data needs to be posted to the page 3 when the user is done (if not for
this then the solution was perfect). Using header() does not post the
data and from what I have read elsewhere there is no way of making it do
this.

I can think of a really ugly solution by way of changing the form's
action to page 3 the first time the Submit (to page 3) button is pressed
and tell the user to press it again to get to page 3 but I don't like
this much.

By the way, I really would prefer to avoid JavaScript.

IRC Online Count
is there any way of getting the online count for an IRC channel? Best,
without creating a user and logging in?...

Count() / Query
I want to query mysql to see how many comments exist for an article. Seems easy enough, and things work ok if there are more than 1 comment. My problem is that if there are 0 comments, the count() function returns 1, and when you click to see the comment, it is a empty. I think the problem must be with the query, but not sure. PHP Code:


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