Re: [PHP] Counting back 90 days...

2004-01-05 Thread Eric Wood
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,

Re: [PHP] Counting back 90 days...

2004-01-05 Thread Paul Chvostek
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

Re: [PHP] Counting elements in an array

2003-11-19 Thread Sophie Mattoug
$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

RE: [PHP] Counting elements in an array

2003-11-19 Thread Jay Blanchard
[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 --

Re: [PHP] Counting elements in an array

2003-11-19 Thread Jason Wong
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

RE: [PHP] Counting elements in an array

2003-11-19 Thread Jeff McKeon
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

Re: [PHP] Counting elements in an array

2003-11-19 Thread Jason Wong
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 =

RE: [PHP] Counting elements in an array

2003-11-19 Thread Jay Blanchard
[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 =

Re: [PHP] Counting elements in an array

2003-11-19 Thread John Nichel
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 =

Re: [PHP] counting files, choosing at random

2003-08-14 Thread Adam i Agnieszka Gasiorowski FNORD
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 ?

Re: [PHP] counting files, choosing at random

2003-08-14 Thread David Otton
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

Re: [PHP] counting words.

2003-04-06 Thread Justin French
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); ?

Re: [PHP] counting words.

2003-04-06 Thread Jome
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));

Re: [PHP] counting ..

2003-03-25 Thread Leif K-Brooks
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

Re: [PHP] counting ..

2003-03-25 Thread Jim Lucas
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

Re: [PHP] counting ..

2003-03-25 Thread Sebastian
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

Re: [PHP] counting ..

2003-03-24 Thread Nikunj Virani
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.

Re: [PHP] counting ..

2003-03-24 Thread Sebastian
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: |

Re: [PHP] counting ..

2003-03-24 Thread Justin French
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

Re: [PHP] Counting table fields having specific values

2003-02-27 Thread Tim Ward
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 =

RE: [PHP] Counting table fields having specific values

2003-02-27 Thread Rich Gray
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

Re: [PHP] counting array elements

2003-02-24 Thread janet
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'

Re: [PHP] counting array elements

2003-02-24 Thread Jason Wong
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

RE: [PHP] counting number of records in a MySQL table; how do I get

2002-10-03 Thread Jay Blanchard
[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

RE: [PHP] counting number of records in a MySQL table; how do I get

2002-10-03 Thread Jason D
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

Re: [PHP] counting number of records in a MySQL table; how do I get

2002-10-03 Thread 1LT John W. Holmes
$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.

RE: [PHP] counting number of records in a MySQL table; how do I get

2002-10-03 Thread Jay Blanchard
[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.

RE: [PHP] counting number of records in a MySQL table; how do I get

2002-10-03 Thread Jay Blanchard
[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,

RE: [PHP] counting number of records in a MySQL table; how do I get

2002-10-03 Thread John W. Holmes
[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

RE: [PHP] counting number of records in a MySQL table; how do I get

2002-10-03 Thread Jay Blanchard
[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

Re: [PHP] counting number of records in a MySQL table; how do I get the result?

2002-10-02 Thread Kevin Stone
$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

Re: [PHP] counting number of records in a MySQL table; how do I getthe result?

2002-10-02 Thread Rasmus Lerdorf
$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

RE: [PHP] counting number of records in a MySQL table; how do I get the result?

2002-10-02 Thread John W. Holmes
$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

Re: [PHP] counting number of records in a MySQL table; how do I get the result?

2002-10-02 Thread Jeff Bluemel
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

Re: [PHP] counting number of records in a MySQL table; how do I get

2002-10-02 Thread Dan Koken
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'];

Re: [PHP] counting words in a string

2002-09-27 Thread Justin French
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 =

RE: [PHP] counting guest users

2002-09-22 Thread Stephen Craton
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,

Re: [PHP] counting max word length fails on line brake

2002-05-15 Thread Analysis Solutions
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

Re: [PHP] counting max word length fails on line brake

2002-05-15 Thread 1LT John W. Holmes
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

Re: [PHP] Counting number of value instances within an array

2002-04-26 Thread andrey
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

Re: [PHP] Counting number of value instances within an array

2002-04-26 Thread Neil Freeman
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

RE: [PHP] Counting months between two dates

2002-04-02 Thread Rick Emery
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

RE: [PHP] Counting months between two dates

2002-04-02 Thread Rick Emery
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

Re: [PHP] counting with dates (help!)

2002-01-09 Thread Peter J. Schoenster
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 =

Re: [PHP] counting with dates (help!)

2002-01-08 Thread Henning Sprang
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

RE: [PHP] counting with dates (help!)

2002-01-07 Thread Martin Towell
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

RE: [PHP] counting with dates (help!)

2002-01-07 Thread Boget, Chris
$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

Re: [PHP] counting with dates (help!)

2002-01-07 Thread Steve Cayford
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!)

2002-01-07 Thread DL Neil
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

RE: [PHP] counting with dates (help!)

2002-01-07 Thread Martin Towell
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

Re: [PHP] Counting Views on records in DB!

2001-12-21 Thread Bas Jobsen
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

Re: [PHP] Counting Views on records in DB!

2001-12-21 Thread Bogdan Stancescu
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

Re: [PHP] Counting Views on records in DB!

2001-12-21 Thread Thomas Edison Jr.
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

Re: [PHP] Counting Views on records in DB!

2001-12-21 Thread Brian Rue
. [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

RE: [PHP] Counting

2001-09-17 Thread Jack Dempsey
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

RE: [PHP] counting number of lines in file() that match a regexp

2001-09-16 Thread Don Read
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;

RE: [PHP] Counting Multidimensional Arrays

2001-08-01 Thread Tim Ward
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;

RE: [PHP] Counting Multidimensional Arrays, Solution Found

2001-07-31 Thread Johnny Nguyen
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

Re: [PHP] Counting Words In a String

2001-04-23 Thread Robert Vetter
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

RE: [PHP] Counting Words In a String

2001-04-22 Thread Greg Donald
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

RE: [PHP] counting files

2001-02-16 Thread Hoover, Josh
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,

RE: [PHP] counting files

2001-02-16 Thread Andrew Rush
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

<    1   2