Paul Chvostek wrote:
Beware timestamps, though. They usually won't work for dates before
1970 or after 2038. If you suspect you'll need to use dates outside
that period (for example, show the 90 days of whatever as of some
date
in 1969), your results may be unpredictable.
For example,
On Mon, Jan 05, 2004 at 09:51:33AM -0500, Eric Wood wrote:
In Business Basic I use Julian Dates:
http://www.basis-documentation.com/commands/jul_function.htm.
This lets me easily calculate days between dates just by substracting
integers. Why has PHP made dates more difficult?
Unix
$i = 0;
foreach ($fruit as $k)
if ('prange' == $k)
$i++;
(The result is $i, of course)
Jeff McKeon wrote:
How would I count the number of elements in an array that had a certain
value?
In other words, if I have
$fruit = array(orange,orange,apple,bananna,orange,apple,pear);
How could I get
[snip]
How would I count the number of elements in an array that had a certain
value?
In other words, if I have
$fruit = array(orange,orange,apple,bananna,orange,apple,pear);
How could I get the number of elements from $fruit where the value is
orange?
[/snip]
http://www.php.net/array_keys
--
On Wednesday 19 November 2003 23:24, Jeff McKeon wrote:
How would I count the number of elements in an array that had a certain
value?
In other words, if I have
$fruit = array(orange,orange,apple,bananna,orange,apple,pear);
How could I get the number of elements from $fruit where the value
Jason Wong wrote:
On Wednesday 19 November 2003 23:24, Jeff McKeon wrote:
How would I count the number of elements in an array that had a
certain value?
In other words, if I have
$fruit = array(orange,orange,apple,bananna,orange,apple,pear);
How could I get the number of elements from
On Thursday 20 November 2003 00:33, Jeff McKeon wrote:
Jason Wong wrote:
On Wednesday 19 November 2003 23:24, Jeff McKeon wrote:
How would I count the number of elements in an array that had a
certain value?
In other words, if I have
$fruit =
[snip]
$fruit = array(orange,orange,apple,bananna,orange,apple,pear);
How could I get the number of elements from $fruit where the value is
orange?
[/snip]
From http://www.php.net/array_keys with additions;
$array = array(blue, red, green, blue, blue);
$countArray =
Jeff McKeon wrote:
How would I count the number of elements in an array that had a certain
value?
In other words, if I have
$fruit = array(orange,orange,apple,bananna,orange,apple,pear);
How could I get the number of elements from $fruit where the value is
orange?
Thanks,
Jeff
$temp =
David Otton wrote:
On Wed, 13 Aug 2003 10:54:58 +0200, you wrote:
I want to choose a file at random from a
directory which adheres to certain naming scheme.
I can't get it to work. It's probably something
simple...Here is a relevant snippet:
img src=/szukaj/images/i
?
On Wed, 13 Aug 2003 10:54:58 +0200, you wrote:
I want to choose a file at random from a
directory which adheres to certain naming scheme.
I can't get it to work. It's probably something
simple...Here is a relevant snippet:
img src=/szukaj/images/i
?
chdir('./szukaj/images/');
echo
It depends on what you define as a word, but let's take the simple approach
of stripping HTML et al, and exploding the string on the spaces, then
counting the array of words:
?
$str = This is my b text /b that I want to count;
$words = explode(' ', strip_tags($str));
$count = count($words);
?
Justin French wrote:
It depends on what you define as a word, but let's take the simple
approach of stripping HTML et al, and exploding the string on the
spaces, then counting the array of words:
?
$str = This is my b text /b that I want to count;
$words = explode(' ', strip_tags($str));
Why do you think comment needs a number in the first place?
Sebastian wrote:
Hello all.
rather dumb question.
I have a pagination system, 25 results per page, which are user comments, I
want to put a number on each comment so i am doing something like:
$num=$num + 1;
$number = $num;
echo
when it comes to the second page, you already know that page you are on
1,2,3,4...
take that and multiply it by the defined number of results per-page, then
start your counting.
Jim
- Original Message -
From: Sebastian [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Monday, March
because my comment system is pretty much like forum style, sometimes a user
referrers to another comment by it's number, etc...
.. and because i want to ;)
cheers,
- Sebastian
- Original Message -
From: Leif K-Brooks [EMAIL PROTECTED]
| Why do you think comment needs a number in the
Check out:
http://phpbuilder.com/columns/rod2221.php3
Hope that helps!
Regards,
Nikunj Virani
- Original Message -
From: Sebastian [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Tuesday, March 25, 2003 11:39 AM
Subject: [PHP] counting ..
Hello all.
rather dumb question.
I Have made my own pagination script, but i am trying give each comment
isn't own number. Which i already did, but when i view the next results it
starts counting from 1 again.
cheers,
Sebastian
- Original Message -
From: Nikunj Virani [EMAIL PROTECTED]
| Check out:
|
Use $num as a global value across all pages, through GET, and use $i for a
per-script counter. Increase both in a loop, add some navigation, and
you're all set...
This should be a starting point...
?
$total_num = 137;
$per_page = 25;
// find value of $num, or start from zero
if ($array = mysql_fetcharray($result))
{echo $array[SUM( hide = 0 )];
}
although for readability I'd prefer an
AS sum_hide in the query and then use
$array[sum_hide]
in general for reading from a mysql result ...
// for a single return row (or the just the first row)
if ($result =
Mike
Try ...
?
$res = mysql_query('select count(*) from names where not hide');
$row = mysql_fetch_row($res);
echo $row[0];
?
Rich
-Original Message-
From: rentAweek support [mailto:[EMAIL PROTECTED]
Sent: 27 February 2003 17:32
To: [EMAIL PROTECTED]
Subject: [PHP] Counting table
In a message dated 2/24/2003 12:05:09 AM Pacific Standard Time,
[EMAIL PROTECTED] writes:
I wish to fine the most occurringest value in an array. eg:
$arr = array('dog', 'cat', 'dog', 'zebra', 'cat', 'dog', 'dog', 'dog');
if I use array_count_values it gives dog = 5
I would like to get 'dog'
On Monday 24 February 2003 16:12, Kevin Waterson wrote:
I wish to fine the most occurringest value in an array. eg:
$arr = array('dog', 'cat', 'dog', 'zebra', 'cat', 'dog', 'dog', 'dog');
if I use array_count_values it gives dog = 5
I would like to get 'dog' and '5' into a $variable.
$arr
[snip]
Or another way if you don't want a result when it's zero.
$rslt = mysql_query(SELECT count(*) as cnt FROM tbl having cnt 0);
[/snip]
$result = mysql_query(SELECT * FROM tbl);
$number_of_rows = mysql_num_rows($result);
You don't have to do the count in the SQL, as John said earlier a
An alternative way is to add a primary or unique key and make the code
snippet like this:
mysql_query(INSERT ignore into AuthNum (FirstNum, LastNum, NextNum, KeyField) VALUES
(1,2,3,1),$dblink);
mysql_query(Update AuthNum Set FirstNum = 1, LastNum = 2, NextNum = 3,$dbLink);
If there is a
$result = mysql_query(SELECT * FROM tbl);
$number_of_rows = mysql_num_rows($result);
You don't have to do the count in the SQL, as John said earlier a SELECT
COUNT(*) FROM tbl will always return one row, even if the value of the row
is 0. Of course you could always test for that.
[snip]
$result = mysql_query(SELECT * FROM tbl);
$number_of_rows = mysql_num_rows($result);
You don't have to do the count in the SQL, as John said earlier a SELECT
COUNT(*) FROM tbl will always return one row, even if the value of the row
is 0. Of course you could always test for that.
[snip]
I still think it's more effecient to use two queries in your case. One with
a COUNT(*) to get total records, and one with a LIMIT to just get the 40 you
want. With a smaller table, it may not matter, but with large tables, you
could be using up a lot of resources by selecting everything,
[snip]
I agree that COUNT is an optimized return, but for a situation where
you
are
retrieving data from the query for whatever use it is more efficient
to
use
mysql_num_rows() to return the count of this particular query than it
would
be to issue a second query, no?
Yes, it all depends
[snip]
I think we're arguing with each other even though we agree on
everything. :)
[/snip]
I prefer to think of it as healthy discussion :^] It is like two quantum
physicists discussing light, with one leaning towards the particle side and
the other leaning towards the wave side. They agree on
$result = mysql_query();
if (mysql_num_rows($result) $x)
-Kevin
- Original Message -
From: DonPro [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Wednesday, October 02, 2002 2:35 PM
Subject: [PHP] counting number of records in a MySQL table; how do I get the
result?
Hi,
I
$ret = mysql_query(SELECT count(*) as foo FROM AuthNum);
$result = mysql_fetch_array($ret);
echo $result['foo'];
One of many ways...
-Rasmus
On Wed, 2 Oct 2002, DonPro wrote:
Hi,
I need to do either an insert or update into a MySQL table. Insert if there
are 0 records or update if one
$result = mysql_query();
if (mysql_num_rows($result) $x)
-Kevin
This won't work because a SELECT COUNT(*) query always returns a row,
even if it returns zero as the value.
$result = mysql_query(SELECT COUNT(*) FROM ... );
$count = mysql_result($result,0);
---John Holmes...
- Original
so why not take that resulting row, and then do an if on it to see if the
value is a zero? an extra step, but it would work
John W. Holmes [EMAIL PROTECTED] wrote in message
002c01c26a66$61f0e1a0$7c02a8c0@coconut">news:002c01c26a66$61f0e1a0$7c02a8c0@coconut...
$result = mysql_query();
if
Or another way if you don't want a result when it's zero.
$rslt = mysql_query(SELECT count(*) as cnt FROM tbl having cnt 0);
HTH..
Have a great day..
Dan
Rasmus Lerdorf wrote:
$ret = mysql_query(SELECT count(*) as foo FROM AuthNum);
$result = mysql_fetch_array($ret);
echo $result['foo'];
if this is your SPECIFIC problem, putting a space at the beginning of $srch
will help, eliminating XAVAILABLE... but this will cause a problem with the
word AVAILABLE appearing at the start of the string, so temporarily put a
space at the start of the string:
?
// UNTESTED
$count =
I'm pretty sure they use cookies and see if the user is logged in or
not. I'm not sure how exactly to make the script though..
Thanks,
Stephen
http://www.melchior.us
http://php.melchior.us
:: -Original Message-
:: From: Andy [mailto:[EMAIL PROTECTED]]
:: Sent: Saturday, September 21,
On Wed, May 15, 2002 at 12:49:30PM +0200, andy wrote:
test
ölakjdfölakjdöfkjaödlfkjöaksdjföl
it asumes thtat the word is: test ölakjdfölakjdöfkjaödlfkjöaksdjföl
$word = explode( ,$string);
Because you're splitting on spaces only. If you want to split on more than just
spaces, you
You might want to look into wordwrap(), too
www.php.net/wordwrap
---John Holmes...
- Original Message -
From: Analysis Solutions [EMAIL PROTECTED]
To: PHP List [EMAIL PROTECTED]
Sent: Wednesday, May 15, 2002 10:42 AM
Subject: Re: [PHP] counting max word length fails on line brake
array_count_values()
HTH
Best regards,
Andrey Hristov
- Original Message -
From: Neil Freeman [EMAIL PROTECTED]
To: PHP General [EMAIL PROTECTED]
Sent: Friday, April 26, 2002 1:24 PM
Subject: [PHP] Counting number of value instances within an array
Hi guys,
Is there a function I
Sorry - don't worry. Found the function I require.
FYI : array_count_values()
Neil Freeman wrote:
*
This Message Was Virus Checked With : SAVI 3.54 Feb 2002
Last Updated 24th April 2002
John,
Are you pulling dates from mysql? If so, let mysql do it for you.
If you don't know how, ask again.
-Original Message-
From: John Hughes [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 02, 2002 12:33 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Counting months between two dates
I
if done in mysql:
SELECT
PERIOD_DIFF(DATE_FORMAT(2002-06-05,%Y%m),(DATE_FORMAT(2001-08-27,%Y%m
) );
-Original Message-
From: John Hughes [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 02, 2002 12:33 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Counting months between two dates
I want to
On 7 Feb 2002, at 23:21, Sander Peters wrote:
Hello,
This is my problem:
$today = date(Ymd, mktime(0,0,0, date(m),date(d),date(Y)));
$last_week = date(Ymd, mktime(0,0,0, date(m),date(d)-7,date(Y)));
echo ($today - $last_week); The result is a number like 8876
(20020107-20011231 =
Sander Peters wrote:
Hello,
This is my problem:
$today = date(Ymd, mktime(0,0,0, date(m),date(d),date(Y)));
$last_week = date(Ymd, mktime(0,0,0, date(m),date(d)-7,date(Y)));
echo ($today - $last_week);
The result is a number like 8876 (20020107-20011231 = 8876)
which is completely
You'll need to use Julian format (I think that the name for it) which is
DDD - is the year and DDD is the number of days into the year. I'm
unsure as to how to do this in PHP so you'll need to do some searching -
unless someone knows... Would be nice to know exactly how to do it in case
$today = date(Ymd, mktime(0,0,0, date(m),date(d),date(Y)));
$last_week = date(Ymd, mktime(0,0,0, date(m),date(d)-7,date(Y)));
echo ($today - $last_week);
The result is a number like 8876 (20020107-20011231 = 8876)
But in date thinking it should be 7!
No, that's the difference in time
Well, I'll chime in as well. I'd recommend doing all your calculations
in timestamps in seconds, then convert the results into days, dates, or
whatever. If you only have a date to start with then convert to a
timestamp, do the calculation, and convert back. You could wrap it in a
function
RE: [PHP] counting with dates (help!)Hi Sander,
(and Chris, and Martin)
$today = date(Ymd, mktime(0,0,0, date(m),date(d),date(Y)));
$last_week = date(Ymd, mktime(0,0,0, date(m),date(d)-7,date(Y)));
echo ($today - $last_week);
The result is a number like 8876 (20020107-20011231 = 8876
for my dates for that reason...
Martin
-Original Message-
From: DL Neil [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 08, 2002 10:42 AM
To: Boget, Chris; 'Sander Peters'; [EMAIL PROTECTED]; Martin
Towell
Subject: Re: [PHP] counting with dates (help!)
RE: [PHP] counting with dates
UPDATE $table views=views+1
Op vrijdag 21 december 2001 21:38, schreef Thomas Edison Jr.:
Hi,
I was just going through some Message Board system and
noticed that there is a Views column which gives how
many times the Message has been viewed.
I created a similar message board, where
To be exact,
update table messages set views=views+1 where id=$msg_id
Bogdan
Bas Jobsen wrote:
UPDATE $table views=views+1
picked up is counted!! Can anyone guide me as to how
this can be achieved?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL
Hi,
UPDATE $table views=views+1
Umm.. can you be a little more specific. I couldn't
make much sense, thought i could get the logic.
Thanks.
T. Edison jr.
Hi,
I was just going through some Message Board system
and
noticed that there is a Views column which gives
how
many times the
. [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, December 21, 2001 12:46 PM
Subject: Re: [PHP] Counting Views on records in DB!
Hi,
UPDATE $table views=views+1
Umm.. can you be a little more specific. I couldn't
make much sense, thought i could get the logic.
Thanks
why not use it in your sql?
select count(*) from table where foo='bar';
-Original Message-
From: Max Mouse [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 17, 2001 5:22 PM
To: php forum
Subject: [PHP] Counting
I'm using php/mysql. I want to be able to count the number of records
On 16-Sep-2001 Kurt Lieber wrote:
I'm trying to take a text file and count the number of lines that match
a regexp. I've got it working using the following code:
$data = file(myfile.txt);
$total = 0;
foreach($data as $i) {
if (ereg(^1,,$i)) {
$total = $total + 1;
I assume that
$m = 07;
$y = 2001;
$d = 31;
echo count($this-arrEvents[$y][$m][$d]);
is in a method of the class that $someclass is a method of, something like:
class fred
{
function dispcount()
{ $m = 07;
$y = 2001;
Nevermind. I Found the solution. $m, $y, and $d must be cast to integers.
-Original Message-
From: Johnny Nguyen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 31, 2001 3:58 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Counting Multidimensional Arrays
Given
Greg Donald wrote:
I want to check a string and return the amount of words present
in it. These
strings could be quite large, some higher than 100,000
characters. I realize
I could explode the string on the whitespace and count the number
of values.
However, I'm not sure this
I want to check a string and return the amount of words present
in it. These
strings could be quite large, some higher than 100,000
characters. I realize
I could explode the string on the whitespace and count the number
of values.
However, I'm not sure this would be the most optimized
Try this bit of code and see if it works. (I don't know if there's a less
taxing (on the server) way to get a count of files in a directory or not.)
$myDirectory = dir("yourdirectory");
while($entry=$myDirectory-read())
{
$filecount++;
}
$myDirectory-close();
$number = rand(1,
On Friday, February 16, 2001, at 10:31 AM, Hoover, Josh wrote:
Try this bit of code and see if it works. (I don't know if there's a less
taxing (on the server) way to get a count of files in a directory or not.)
this code snippet won't work as a standalone. you are referencing an object
101 - 162 of 162 matches
Mail list logo