Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Jim Lucas
On 1/28/2011 11:23 AM, David Harkness wrote: > On Fri, Jan 28, 2011 at 11:03 AM, Marc Guay wrote: > >> If COUNTing is the heavy part, why not create a 'users_logged_in' >> field somewhere and increment it when someone logs in and decrement it >> when someone logs out? Then your query is just a s

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread David Harkness
On Fri, Jan 28, 2011 at 11:03 AM, Marc Guay wrote: > If COUNTing is the heavy part, why not create a 'users_logged_in' > field somewhere and increment it when someone logs in and decrement it > when someone logs out? Then your query is just a straight SELECT. If this is like most web sites, us

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Marc Guay
> I'm looking for a faster way to count online users. COUNT(*) is time > consuming under MySQL. If COUNTing is the heavy part, why not create a 'users_logged_in' field somewhere and increment it when someone logs in and decrement it when someone logs out? Then your query is just a straight SELEC

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread David Harkness
If you're using memcached already you could store the number in it and update it only when a user logs in/out. If no one is logging in/out, the number isn't changing. If your site is so popular that hundreds of users are logging in every second you might want to change the logic so that the proces

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread AmirBehzad Eslami
Jim, I'm already using the solution you mentioned. The problem is about the performance. One solution is to increase the performance by using Memcached. But counting online users always requires a __new__fresh__ COUNT(*) query, even under Memcahched. Since the COUNT(*) result is very dynamic and

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Jim Lucas
On 1/28/2011 9:57 AM, AmirBehzad Eslami wrote: > Dear list, > > The common solution for counting online users is to store sessions in a Table. > I've created a Table in MySQL to acheive the result, but it seems this > solution > is a little heavy for such a simple task. > > Is there a better alt

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Fernando
How did you created the table? Can you count the Id's only? Wouldn't this just count the entries in the index? On 28/01/2011 12:57, AmirBehzad Eslami wrote: Dear list, The common solution for counting online users is to store sessions in a Table. I've created a Table in MySQL to acheive the

[PHP] Counting Children!

2010-09-13 Thread Sridhar Pandurangiah
Hi I have an XML generated by another computer application. The format is as below. (Don't worry about the data in the XML. Its the test data). I am able to locate the correct member bill using XPATH. However I have hit a bottleneck. I am unable to echo all the elements. This is what happens

Re: [PHP] Counting Occurrences within an If statement

2008-07-20 Thread Micah Gersten
If it's a simple x < y, you might want to consider putting your if statement in the SQL query so you don't return so many rows. To make a counter, just set a variable like: $counter = 0; if ($x <$y) { print $row; $counter++ } Thank you, Micah Gersten onShore Networks Internal Developer h

[PHP] Counting Occurrences within an If statement

2008-07-20 Thread Mark Bomgardner
I have been working on the something for the last day and can't figure it out. I am pulling 7500 rows from a MySQL database, but I only want to display a certain numbers of rows based up an if statement. I want to count the rows within the if statement. mysql query result if(x < y){ d

Re: [PHP] counting with leading zeros

2007-10-01 Thread Martin Alterisio
// glob returns an ordered list (rtfm: man glob) // relies on the use of the operator ++ to generate string sequences. function lastFileInSequence($path, $prefix, $first, $suffix) { return array_pop(glob($path . "/" . $prefix . str_repeat('?', strlen($first)) . $suffix)); } function nextFileI

Re: [PHP] counting with leading zeros

2007-09-30 Thread tedd
At 11:47 PM -0400 9/29/07, brian wrote: You and i have had our run-ins on this list on more than one occasion. Until now, i've chosen to take your crap in stride. brian I haven't noticed any "run-ins". I don't care if you've been the biggest prick on the net -- if you ask a question and it's

Re: [PHP] counting with leading zeros

2007-09-30 Thread Jeffery Fernandez
gee you guys behave like kids. don't you all have other things to do than whinge, swear and blame each other on the list? Take it elsewhere and sort it out. This is bad for the PHP community in general. It doesn't reflect what the community is about. my 2c. On Sunday 30 September 2007 13:47,

Re: [PHP] counting with leading zeros

2007-09-30 Thread Robert Cummings
On Sat, 2007-09-29 at 23:47 -0400, brian wrote: > > It's not so much that i disrespect Rob. It's just that i felt i had to > call him out for being a dickhead by taking my statement out of context. Ok, so I'm a dickhead. What does that make you? A vagina? Name calling really is the lowest form o

Re: [PHP] counting with leading zeros

2007-09-29 Thread brian
tedd wrote: At 8:30 PM -0400 9/27/07, brian wrote: I wasn't bitching! And i *thought* that my numerous attempts at explaining such would have been enough. Obviously not, but wtf can you do with people who seem to want only to stir up shit? It sure sounded like you were bitching. Gee, thanks

RE: [PHP] counting with leading zeros

2007-09-28 Thread Dan Parry
; From: tedd [mailto:[EMAIL PROTECTED] > Sent: 28 September 2007 17:20 > To: brian; php-general@lists.php.net > Subject: Re: [PHP] counting with leading zeros > > At 8:30 PM -0400 9/27/07, brian wrote: > >I wasn't bitching! And i *thought* that my numerous attempts at &g

Re: [PHP] counting with leading zeros

2007-09-28 Thread tedd
At 8:30 PM -0400 9/27/07, brian wrote: I wasn't bitching! And i *thought* that my numerous attempts at explaining such would have been enough. Obviously not, but wtf can you do with people who seem to want only to stir up shit? It sure sounded like you were bitching. And, your off-list "fuck y

Re: [PHP] counting with leading zeros

2007-09-27 Thread brian
tedd wrote: At 3:58 PM -0400 9/26/07, brian wrote: Well, this is almost precisely the same thing i have, save for using POSIX character classes, str_pad instead of sprintf(), and incrementing elsewhere. What i was really wondering is if there was a *much simpler* way to do this, not just re-

Re: [PHP] counting with leading zeros

2007-09-27 Thread tedd
At 10:39 PM -0400 9/26/07, brian wrote: Now you're obviously just trying to be a dickhead. While someone is, it's not Rob. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: h

Re: [PHP] counting with leading zeros

2007-09-27 Thread tedd
Robert Cummings wrote: Suit yourself. But better programmer's don't just wave their hands in the air and hope for the best. Ah crap -- there's another technique I have to cross off my list. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PH

Re: [PHP] counting with leading zeros

2007-09-27 Thread tedd
At 3:58 PM -0400 9/26/07, brian wrote: Well, this is almost precisely the same thing i have, save for using POSIX character classes, str_pad instead of sprintf(), and incrementing elsewhere. What i was really wondering is if there was a *much simpler* way to do this, not just re-arranging thing

Re: [PHP] counting with leading zeros

2007-09-27 Thread Robert Cummings
On Wed, 2007-09-26 at 21:56 -0700, Jim Lucas wrote: > > Now, if you plan to delete any images in the list, this will not work. > > But if you don't expect to delete any images in the list and always want > the ($total_images + 1), then follow along. > > > function getNextImage($path, $prefix)

Re: [PHP] counting with leading zeros

2007-09-26 Thread Jim Lucas
brian wrote: I have a directory that contains many images (no, not pr0n, unfortunately) and i'm working on an admin script for adding to it. I've got something that works alright but i'm wondering if there's a Better Way. Each image is named like: foo_01.jpg, foo_02.jpg, bar_01.jpg, and so on.

Re: [PHP] counting with leading zeros

2007-09-26 Thread Robert Cummings
On Thu, 2007-09-27 at 00:23 -0400, brian wrote: > Robert Cummings wrote: > > When you use sort() the default behaviour is a lexical sort. This is why > > the 100th index breaks your system. I'm not trying to be a dickhead, > > just pointing out the flaw in your logic. You may be well aware that in

Re: [PHP] counting with leading zeros

2007-09-26 Thread brian
Robert Cummings wrote: When you use sort() the default behaviour is a lexical sort. This is why the 100th index breaks your system. I'm not trying to be a dickhead, just pointing out the flaw in your logic. You may be well aware that in counting 100 comes after 99, but it would seem you are not w

Re: [PHP] counting with leading zeros

2007-09-26 Thread Robert Cummings
On Wed, 2007-09-26 at 22:39 -0400, brian wrote: > Robert Cummings wrote: > > On Wed, 2007-09-26 at 19:10 -0400, brian wrote: > > > >>If my response to that gave you the impression i was > >>complaining, i assure you that i wasn't. I was simply suggesting > >>that i was wondering if there was a *mu

Re: [PHP] counting with leading zeros

2007-09-26 Thread brian
Robert Cummings wrote: On Wed, 2007-09-26 at 19:10 -0400, brian wrote: If my response to that gave you the impression i was complaining, i assure you that i wasn't. I was simply suggesting that i was wondering if there was a *much* simpler way to do this, ie. without using several functions to

Re: [PHP] counting with leading zeros

2007-09-26 Thread Robert Cummings
On Wed, 2007-09-26 at 19:10 -0400, brian wrote: > Robert Cummings wrote: > > >> Well, this is almost precisely the same thing i have, save for > >> using POSIX character classes, str_pad instead of sprintf(), and > >> incrementing elsewhere. What i was really wondering is if there was > >> a *mu

Re: [PHP] counting with leading zeros

2007-09-26 Thread brian
Robert Cummings wrote: On Wed, 2007-09-26 at 15:58 -0400, brian wrote: Robert Cummings wrote: On Wed, 2007-09-26 at 15:11 -0400, brian wrote: I have a directory that contains many images (no, not pr0n, unfortunately) and i'm working on an admin script for adding to it. I've got something

Re: [PHP] counting with leading zeros

2007-09-26 Thread Robert Cummings
On Wed, 2007-09-26 at 15:58 -0400, brian wrote: > Robert Cummings wrote: > > On Wed, 2007-09-26 at 15:11 -0400, brian wrote: > > > >>I have a directory that contains many images (no, not pr0n, > >>unfortunately) and i'm working on an admin script for adding to it. I've > >>got something that wor

Re: [PHP] counting with leading zeros

2007-09-26 Thread brian
Robert Cummings wrote: On Wed, 2007-09-26 at 15:11 -0400, brian wrote: I have a directory that contains many images (no, not pr0n, unfortunately) and i'm working on an admin script for adding to it. I've got something that works alright but i'm wondering if there's a Better Way. Each image i

Re: [PHP] counting with leading zeros

2007-09-26 Thread Robert Cummings
On Wed, 2007-09-26 at 15:11 -0400, brian wrote: > I have a directory that contains many images (no, not pr0n, > unfortunately) and i'm working on an admin script for adding to it. I've > got something that works alright but i'm wondering if there's a Better Way. > > Each image is named like: foo

[PHP] counting with leading zeros

2007-09-26 Thread brian
I have a directory that contains many images (no, not pr0n, unfortunately) and i'm working on an admin script for adding to it. I've got something that works alright but i'm wondering if there's a Better Way. Each image is named like: foo_01.jpg, foo_02.jpg, bar_01.jpg, and so on. When adding

Re: [PHP] Counting Capital Letters

2007-06-21 Thread tedd
At 12:32 AM +0100 6/21/07, Richard Davey wrote: Hi, I've written a short regexp which will *count* how many capital letters are in a given string (the woefully simple: '/[A-Z]/') Although it's an English language web site, I'm curious how you'd count capital letters that span beyond just the st

Re: [PHP] Counting Capital Letters

2007-06-21 Thread Robin Vickery
On 21/06/07, Richard Davey <[EMAIL PROTECTED]> wrote: Hi, I've written a short regexp which will *count* how many capital letters are in a given string (the woefully simple: '/[A-Z]/') Although it's an English language web site, I'm curious how you'd count capital letters that span beyond just

[PHP] Counting Capital Letters

2007-06-20 Thread Richard Davey
Hi, I've written a short regexp which will *count* how many capital letters are in a given string (the woefully simple: '/[A-Z]/') Although it's an English language web site, I'm curious how you'd count capital letters that span beyond just the standard A-Z. For example characters such as the La

Re: [PHP] counting code lines

2007-06-14 Thread James McLean
On 6/15/07, Toni Torello <[EMAIL PROTECTED]> wrote: hi guys, just supposing... which is the right way to to count the number of code lines in a php application? do you think that the raw: $ find . -name '*.php' -exec cat {} \; | wc -l can be a good estimate? I recently desired to know a simil

[PHP] counting code lines

2007-06-14 Thread Toni Torello
hi guys, just supposing... which is the right way to to count the number of code lines in a php application? do you think that the raw: $ find . -name '*.php' -exec cat {} \; | wc -l can be a good estimate? just a curiosity: according to this criteria... phpmyadmin ~ 12 code lines drupal ~ 6

Re: [PHP] counting hyperlink clicks in php

2007-02-20 Thread Richard Lynch
On Sat, February 17, 2007 1:53 pm, clive wrote: > Denis L. Menezes wrote: >> Dear friends. >> >> I have a site where I have news headers. I wish to count the clicks >> on the >> news headers so that I can see how many times each of the the news >> has been >> viewed. This way I can show the "most v

Re: [PHP] counting hyperlink clicks in php

2007-02-20 Thread Fergus Gibson
Brad Bonkoski wrote: > I think the best way to do this would be to set an onClick (Javascript) > event handler for each of the links, and then use AJAX style stuff to > send the information to PHP on the server side, then PHP can log the > link that was clicked, and keep track of the most clicked l

Re: [PHP] counting hyperlink clicks in php

2007-02-17 Thread clive
Denis L. Menezes wrote: Dear friends. I have a site where I have news headers. I wish to count the clicks on the news headers so that I can see how many times each of the the news has been viewed. This way I can show the "most viewed" news. Can one of you please advise hwo this can be done?

Re[2]: [PHP] counting hyperlink clicks in php

2007-02-17 Thread Ed Grigoryan
Hello Brad, Saturday, February 17, 2007, 4:22:22 PM, you wrote: > Denis L. Menezes wrote: >> Dear friends. >> >> I have a site where I have news headers. I wish to count the clicks on the >> news headers so that I can see how many times each of the the news has been >> viewed. This way I can show

Re: [PHP] counting hyperlink clicks in php

2007-02-17 Thread Brad Bonkoski
Denis L. Menezes wrote: Dear friends. I have a site where I have news headers. I wish to count the clicks on the news headers so that I can see how many times each of the the news has been viewed. This way I can show the "most viewed" news. Can one of you please advise hwo this can be done?

[PHP] counting hyperlink clicks in php

2007-02-17 Thread Denis L. Menezes
Dear friends. I have a site where I have news headers. I wish to count the clicks on the news headers so that I can see how many times each of the the news has been viewed. This way I can show the "most viewed" news. Can one of you please advise hwo this can be done? Thanks Denis -- PHP Gen

Re: [PHP] Counting the occurences of items in an array

2006-12-24 Thread Dotan Cohen
Thanks for the link to the function. Know that I did RTFM before posting, but I missed that one. Dotan Cohen http://lyricslist.com/lyrics/artist_albums/219/xyz.php http://simplesniff.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Counting the occurences of items in an array

2006-12-24 Thread tedd
At 8:35 PM +0200 12/24/06, Dotan Cohen wrote: Has this wheel been invented, but simpler? I've an array of words that I'd like to know how many occurences of each there are. For instance: $fruits = array( "lemon", "orange", "banana", "apple", "orange", "banana", "orange");

Re: [PHP] Counting the occurences of items in an array

2006-12-24 Thread Sumeet
Dotan Cohen wrote: Has this wheel been invented, but simpler? I've an array of words that I'd like to know how many occurences of each there are. For instance: $fruits = array( "lemon", "orange", "banana", "apple", "orange", "banana", "orange"); And I'd like to create th

[PHP] Counting the occurences of items in an array

2006-12-24 Thread Dotan Cohen
Has this wheel been invented, but simpler? I've an array of words that I'd like to know how many occurences of each there are. For instance: $fruits = array( "lemon", "orange", "banana", "apple", "orange", "banana", "orange"); And I'd like to create this: $fruit_count = a

Re: [PHP] counting clicks

2006-11-29 Thread clive
Ross wrote: Anyone got a script so I can count clicks on adverts. Doesn't have tosve to myqsl or anything just a text file will do. What about using mysql, but use a memory resident heap table, then every once in a while write this to a file or even better to a myisam table Ta Ross -

RE: [PHP] counting clicks

2006-11-29 Thread Jay Blanchard
[snip] This has a race condition where a busy server, or even a not-so-busy one where 2 people happen to click at the same time, at least one of them will be "missed", at best. There's also a distinct possiblity of the counter file getting completely trashed, depending on the OS and its underlying

RE: [PHP] counting clicks

2006-11-29 Thread Richard Lynch
On Wed, November 29, 2006 11:21 am, Jay Blanchard wrote: > [snip] > Anyone got a script so I can count clicks on adverts. Doesn't have > tosve > to > myqsl or anything just a text file will do. > [/snip] > > > if("yes" == $adClicked){ >$adClickCountFile = fopen("countClick.txt", "w"); >$ge

RE: [PHP] counting clicks

2006-11-29 Thread Jay Blanchard
[snip] Anyone got a script so I can count clicks on adverts. Doesn't have tosve to myqsl or anything just a text file will do. [/snip] YMMV -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] counting clicks

2006-11-29 Thread Ross
Anyone got a script so I can count clicks on adverts. Doesn't have tosve to myqsl or anything just a text file will do. Ta Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] counting records in db

2006-10-31 Thread Robert Cummings
On Tue, 2006-10-31 at 11:58 +0100, Robin Vickery wrote: > On 30/10/06, Robert Cummings <[EMAIL PROTECTED]> wrote: > > On Mon, 2006-10-30 at 12:28 +0100, Robin Vickery wrote: > > > On 30/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: > > > > On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wr

Re: [PHP] counting records in db

2006-10-31 Thread Richard Lynch
On Tue, October 31, 2006 4:58 am, Robin Vickery wrote: > On 30/10/06, Robert Cummings <[EMAIL PROTECTED]> wrote: >> On Mon, 2006-10-30 at 12:28 +0100, Robin Vickery wrote: >> > On 30/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: >> > > On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote:

Re: [PHP] counting records in db

2006-10-31 Thread Robin Vickery
On 30/10/06, Robert Cummings <[EMAIL PROTECTED]> wrote: On Mon, 2006-10-30 at 12:28 +0100, Robin Vickery wrote: > On 30/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: > > On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: > > > > > On Fri, October 27, 2006 4:53 pm, Børge Holen wrote:

Re: [PHP] counting records in db

2006-10-31 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-27 20:14:58 +0200: > > And the header("Location: ...") requires a full URL. > Why? HTTP protocol specification[1] says: 14.30 Location The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion

Re: [PHP] counting records in db

2006-10-31 Thread Ivo F.A.C. Fokkema
On Mon, 30 Oct 2006 12:28:29 +0100, Robin Vickery wrote: > On 30/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: >> On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: >> > On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: >> >> On Friday 27 October 2006 19:34, Richard Lynch wrote: >>

Re: [PHP] counting records in db

2006-10-30 Thread Robert Cummings
On Mon, 2006-10-30 at 12:28 +0100, Robin Vickery wrote: > On 30/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: > > On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: > > > > > On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: > > >> On Friday 27 October 2006 19:34, Richard Lynch wrot

Re: [PHP] counting records in db

2006-10-30 Thread Robin Vickery
On 30/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: > On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: >> On Friday 27 October 2006 19:34, Richard Lynch wrote: >>> And the header("Location: ...") requires a full URL. >> >> No it

Re: [PHP] counting records in db

2006-10-30 Thread Ivo F.A.C. Fokkema
On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: > On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: >> On Friday 27 October 2006 19:34, Richard Lynch wrote: >>> And the header("Location: ...") requires a full URL. >> >> No it doesn't. but he's missing an ' at first glance > > Yes, it

Re: [PHP] counting records in db

2006-10-29 Thread Richard Lynch
On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: > On Friday 27 October 2006 19:34, Richard Lynch wrote: >> And the header("Location: ...") requires a full URL. > > No it doesn't. but he's missing an ' at first glance Yes, it does: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3

Re: [PHP] counting records in db

2006-10-29 Thread Richard Lynch
On Fri, October 27, 2006 12:14 pm, [EMAIL PROTECTED] wrote: >> And the header("Location: ...") requires a full URL. > Why? Because the docs say so? Because some user agents will not do what you want them to if you don't? -- Some people have a "gift" link here. Know what I want? I want you to bu

Re: [PHP] counting records in db

2006-10-27 Thread Børge Holen
On Friday 27 October 2006 19:34, Richard Lynch wrote: > Your idea to use 'COUNT(Username)' is just about the ONLY part of that > script that you are doing correctly... > > :-) > > Start reading here: > http://phpsec.org/ > > And the header("Location: ...") requires a full URL. No it doesn't. but h

Re: [PHP] counting records in db

2006-10-27 Thread afan
> Your idea to use 'COUNT(Username)' is just about the ONLY part of that > script that you are doing correctly... > > :-) :D > And the header("Location: ...") requires a full URL. Why? > And you should have better error-checking, probably. > [Though maybe you have a custom error handler not ap

Re: [PHP] counting records in db

2006-10-27 Thread Richard Lynch
Your idea to use 'COUNT(Username)' is just about the ONLY part of that script that you are doing correctly... :-) Start reading here: http://phpsec.org/ And the header("Location: ...") requires a full URL. And you should have better error-checking, probably. [Though maybe you have a custom erro

Re: [PHP] counting records in db

2006-10-27 Thread Satyam
- Original Message - From: "Paul Novitski" <[EMAIL PROTECTED]> While we're talking about optimization, I'd want to check to make sure COUNT(*) didn't ask MySQL to generate a throw-away recordset consisting of all fields. I wonder if it would be more machine-efficient to use COUNT(`la

Re: [PHP] counting records in db

2006-10-26 Thread afan
>>Would it be ok to use the same code to check if customer is loged in? >> >>$query = mysql_query(" >>SELECT COUNT(Username) as NoOfRecords >>FROM customers >>WHERE Username = '$Username' AND Password = >> '$Password'"); >>if (mysql_result($query, 0)

Re: [PHP] counting records in db

2006-10-26 Thread Paul Novitski
At 10/26/2006 11:16 AM, [EMAIL PROTECTED] wrote: Would it be ok to use the same code to check if customer is loged in? $query = mysql_query(" SELECT COUNT(Username) as NoOfRecords FROM customers WHERE Username = '$Username' AND Password = '$Password'"

RE: [PHP] counting records in db

2006-10-26 Thread Brad Fuller
> Would it be ok to use the same code to check if customer is loged in? > > $query = mysql_query(" >SELECT COUNT(Username) as NoOfRecords >FROM customers >WHERE Username = '$Username' AND Password = '$Password'"); > if (mysql_result($query, 0) == 0)

Re: [PHP] counting records in db

2006-10-26 Thread Dave Goodchild
Why would you want to do that? Think about what you're trying to do. In the first case you want a COUNT of records in the database, in the second you just want to see if the user/password combination or whatever exist, so just use a normal SELECT query, no need to use the wrong tool for the job...

Re: [PHP] counting records in db

2006-10-26 Thread afan
Would it be ok to use the same code to check if customer is loged in? $query = mysql_query(" SELECT COUNT(Username) as NoOfRecords FROM customers WHERE Username = '$Username' AND Password = '$Password'"); if (mysql_result($query, 0) == 0) { echo 'Ple

Re: [PHP] counting records in db

2006-10-26 Thread Richard Lynch
On Thu, October 26, 2006 12:57 pm, Paul Novitski wrote: >>$query = mysql_query(" >> SELECT COUNT(*) as NoOfRecords >> FROM customers >> WHERE last_name = 'Smith'"); >>$result = mysql_fetch_array($query); >>$NoOfRecords = $result['NoOfRecords']; This

Re: [PHP] counting records in db

2006-10-26 Thread afan
Sorry, my bad! It works jsut fine. I did misstake. :) >> >> >> > $query = mysql_query(" >> >SELECT COUNT(*) as NoOfRecords >> >FROM customers >> >WHERE last_name = 'Smith'"); >> > $result = mysql_result($query, 0); >> > -- PHP General Mailing List

Re: [PHP] counting records in db

2006-10-26 Thread Paul Novitski
At 10/26/2006 10:38 AM, [EMAIL PROTECTED] wrote: what would be better solution to count records in table (e.g., how many customers have last name 'Smith'): $query = mysql_query(" SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smit

Re: [PHP] counting records in db

2006-10-26 Thread afan
Hm. There is a little problem - this doesn't work. Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/html/xxx/tests/count.php on line 28 ? > $query = mysql_query(" >SELECT COUNT(*) as NoOfRecords >FROM customers >

Re: [PHP] counting records in db

2006-10-26 Thread afan
WOW! That was fast! :D Thanks Dave! -afan > $query = mysql_query(" >SELECT COUNT(*) as NoOfRecords >FROM customers >WHERE last_name = 'Smith'"); > $result = mysql_result($query, 0); > -- PHP General Mailing List (http://www.php.net/) To unsubscr

Re: [PHP] counting records in db

2006-10-26 Thread Dave Goodchild
$query = mysql_query(" SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smith'"); $result = mysql_result($query, 0);

[PHP] counting records in db

2006-10-26 Thread afan
hi! what would be better solution to count records in table (e.g., how many customers have last name 'Smith'): $query = mysql_query(" SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smith'"); $result = mysql_fetch_array($query); $No

Re: [PHP] Counting files in directory and subdirectory!

2006-01-25 Thread David Tulloh
That is some nasty code... Anything that has repitition like that needs a substantial rewrite, but I'm guessing that you know that, hence the e-mail. I just knocked up the following function, powered by the magic of recursion. It should be close to what you were trying to do. function count_fil

Re: [PHP] Counting files in directory and subdirectory!

2006-01-25 Thread Nicholas Couloute
here is what I tried but it doesn't work! any advice suggestions or something? $count = 0; $dir = "/amrs"; $files1 = scandir($dir); if ($files1 !== '.' && $files1 !== '..') { foreach ($files1 as $files2){ $dir2 = "/amrs/$files2"; $files3 = scandir($dir2); if ($files3 !== '.' && $files3 !== '..')

Re: [PHP] Counting files in directory and subdirectory!

2006-01-25 Thread Nicholas Couloute
I have used these functions but how would I count them! here is my attempt that doesn't work!: $count = 0; $dir = "/amrs"; $files1 = scandir($dir); if ($files1 !== '.' && $files1 !== '..') { foreach ($files1 as $files2){ $dir2 = "/amrs/$files2"; $files3 = scandir($dir2); if ($files3 !== '.' && $f

RE: [PHP] Counting files in directory and subdirectory!

2006-01-25 Thread Weber Sites LTD
ites.com -Original Message- From: Nicholas Couloute [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 25, 2006 9:41 PM To: php-general@lists.php.net Subject: [PHP] Counting files in directory and subdirectory! I want a script where it will count all the amrs in a folder and it's sub

Re: [PHP] Counting files in directory and subdirectory!

2006-01-25 Thread tomasz abramowicz
start here: http://www.php.net/readdir check out as well: 'string functions' for finding 'amrs' and loops to make recursive search... t. Nicholas Couloute wrote: I want a script where it will count all the amrs in a folder and it's sub folders like this setup: amrs > 50 cent > amrs ni

[PHP] Counting files in directory and subdirectory!

2006-01-25 Thread Nicholas Couloute
I want a script where it will count all the amrs in a folder and it's sub folders like this setup: amrs > 50 cent > amrs nitty > amrs bob > amrs How would I do this? ~Nick Couloute co-owner/Web Designer Sidekick2Music.Com -- PHP General Mailing List (http://www.php.net/)

RE: [PHP] Counting in Hex

2006-01-04 Thread Ben Miller
Never mind - wasn't adding properly. Found it after all on php.net, anyway. Thanks anyway. -Original Message- From: Ben Miller [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 04, 2006 5:01 PM To: php-general@lists.php.net Subject: [PHP] Counting in Hex Is there a way in PHP to

[PHP] Counting in Hex

2006-01-04 Thread Ben Miller
Is there a way in PHP to count using hex instead of numerals so that the following statement $var = 237F; $var++; echo "$var"; would result in 2380 Thanks a bunch. Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] counting nested array

2005-08-17 Thread Ing . Josué Aranda
hahaha, thanks robin you save some seconds of mi life... it looks more "pro" with that if... On 8/17/05, Robin Vickery <[EMAIL PROTECTED]> wrote: > On 8/17/05, Ing. Josué Aranda <[EMAIL PROTECTED]> wrote: > > OK this the little function i made to solve this.. > > > > function countNested($arra

Re: [PHP] counting nested array

2005-08-17 Thread Robin Vickery
On 8/17/05, Ing. Josué Aranda <[EMAIL PROTECTED]> wrote: > OK this the little function i made to solve this.. > > function countNested($array){ > foreach($array as $value){ > if(is_array($value)) > $total=$this->countNested($value)+$total; > }els

Re: [PHP] counting nested array

2005-08-16 Thread Ing . Josué Aranda
OK this the little function i made to solve this.. [CODE] function countNested($array){ foreach($array as $value){ if(is_array($value)) $total=$this->countNested($value)+$total; }else{ $total=$total+1; } }

Re: [PHP] counting nested array

2005-08-16 Thread Robin Vickery
On 8/16/05, Ing. Josué Aranda <[EMAIL PROTECTED]> wrote: > > The number of the branches is not always the same.. (it depends on the > query).. when i use count($array, COUNT_RECURSIVE) for nested arrays.. > it give to me the total including the nodes in the branches ( in this > case 28).. now here

Re: [PHP] counting nested array

2005-08-16 Thread Torgny Bjers
Ing. Josué Aranda wrote: >Hi to everyone.. > >now i have a little problem counting an nested array. Im using it to >fill a Java TreeView... it looks like this: > >[snip] > >The number of the branches is not always the same.. (it depends on the >query).. when i use count($array, COUNT_RECURSIVE) fo

[PHP] counting nested array

2005-08-16 Thread Ing . Josué Aranda
Hi to everyone.. now i have a little problem counting an nested array. Im using it to fill a Java TreeView... it looks like this: [1] => Array ( [1] => Array ( [1] => Array ( [1] => LEC

Re: [PHP] counting ocuring words in a string

2005-05-17 Thread Jason Wong
On Tuesday 17 May 2005 18:00, Merlin wrote: > I am trying to find a way to count the number of times (if any) words > are inside a string. explode() array_count_values() -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting

Re: [PHP] counting ocuring words in a string

2005-05-17 Thread Brian V Bonini
On Tue, 2005-05-17 at 06:00, Merlin wrote: > Hi there, > > I am trying to find a way to count the number of times (if any) words are > inside > a string. So I played around with ereg, preg_match_all and so on, but could > not > put together a working code. Maybe something like this? '; fore

Re: [PHP] counting ocuring words in a string

2005-05-17 Thread Petar Nedyalkov
On Tuesday 17 May 2005 13:00, Merlin wrote: > Hi there, > > I am trying to find a way to count the number of times (if any) words are > inside a string. So I played around with ereg, preg_match_all and so on, > but could not put together a working code. > > Can anybody help me on that? > > This is

[PHP] counting ocuring words in a string

2005-05-17 Thread Merlin
Hi there, I am trying to find a way to count the number of times (if any) words are inside a string. So I played around with ereg, preg_match_all and so on, but could not put together a working code. Can anybody help me on that? This is the current code: function count_words($str, $words) { if

Re: [PHP] Counting numbers on while..

2005-03-28 Thread Devraj Mukherjee
You basically dont need the for loop all you have to do is increment the value of the variable by one each time in the while loop Devraj Louie Miranda wrote: Hi, im trying to create a number loop on a table where the data came in a database. I have tried the for "loop" and counted $countCards_res

[PHP] Counting numbers on while..

2005-03-28 Thread Louie Miranda
Hi, im trying to create a number loop on a table where the data came in a database. I have tried the for "loop" and counted $countCards_result from the table where im going to get all the data. ## code ## while ($profile->fetchInto($row)) { for ($i = 1; $i <= $countCards_result; $i++) { $num = $

Re: [PHP] counting chars..

2004-12-15 Thread Robby Russell
On Thu, 2004-12-16 at 14:28 +0800, Louie Miranda wrote: > $string = "function yes good"; > $display = count_chars($string); > > echo $display; > ?> > > i know this is wrong, but how can i count chars used here? php.net/strlen ? -Robby -- /*** * Robby Russel

  1   2   3   >