php-general Digest 12 Jul 2008 07:36:59 -0000 Issue 5564

Topics (messages 276662 through 276682):

Re: What font/size do you use for programming?
        276662 by: Eric Butera

Re: Question regarding OO
        276663 by: Eric Butera
        276666 by: Eric Butera
        276667 by: Jay Blanchard
        276671 by: Boyd, Todd M.

Re: Relocating and POSTing
        276664 by: tedd
        276665 by: Daniel Brown
        276669 by: tedd

Re: cookie encoding/decoding
        276668 by: Jeff Demel

Re: OT - RE: [PHP] scalable web gallery
        276670 by: Boyd, Todd M.
        276672 by: tedd
        276673 by: Jim Lucas
        276674 by: Shawn McKenzie
        276675 by: Shawn McKenzie
        276676 by: Jim Lucas
        276680 by: tedd

Re: scalable web gallery
        276677 by: paragasu
        276681 by: tedd

Most popular per month
        276678 by: Ryan S
        276679 by: Wolf

case and accent - insensitive regular expression?
        276682 by: Giulio Mastrosanti

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
On Thu, Jul 10, 2008 at 5:29 PM, Philip Thompson <[EMAIL PROTECTED]> wrote:
> On Jul 10, 2008, at 3:35 PM, Omar Noppe wrote:
>
>> Is there any reason to pick a black background en white fonts in your
>> editor (for example writability)?
>
> I think a black background is much easier on the eyes....

I use a big font on a black background because it doesn't strain my
eyes as much.  I started out with Monaco 9pt (or bitstream vera sans
mono 9pt on linux) on white.  Slowly though I kept getting more
frequent headaches.  Now I use black with big fonts and I'm fine.  I
have really good vision and all that, but just hours of coding will
get to me.

As a side bonus, using a bigger font also helps me adhere to wrapping
at the 80 character margin too.

--- End Message ---
--- Begin Message ---
On Fri, Jul 11, 2008 at 12:03 PM, Yeti <[EMAIL PROTECTED]> wrote:
> <?php
>
> /*
>
> I have a question here regarding object orientation in PHP and any other
> language.
>
> Let's start with some hypothetical code:
>
> */
>
> // <--- 1st CLASS
>
> class ParkingLot {
>
> var size; // size in sq feet
>
> var max_number_of_cars; // how many cars there is space for
>
> function __construct($size, $max_cars) {
>
> $this->size = $size; $this->max_number_of_cars = $max_cars;
>
> }
>
> };
>
> cpark = new ParkingLot(50000, 17);
>
> // <--- 2nd CLASS
>
> class ParkingSpace extends ParkingLot {
>
> var ps_ID; // ID of the parking space ( 1 .. max_number_of_cars )
>
> var occupied_by; // ID of the car on the parking space
>
> var st_time; // Unix time stamp set when the car parks
>
> function __construct($car, $id) {
>
> $this->st_time = time();
>
> $this->occupied_by = $car;
>
> $this->ps_ID = $id;
>
> }
>
> };
>
> /*
>
> OK, so i got a parking lot class and its subclass parking space.
>
> Now the question:
>
> I want a list of occupied parking spaces, where do I put that? One might put
> it into the ParkingLot Class, but wouldn't that be a recursion (a child
> instance in the parent class)?
>
> */
>
> $occ_parking_spaces = array();
>
> $occ_parking_spaces[] =& new ParkingSpace('Joes Car', 8);
>
> $occ_parking_spaces[] =& new ParkingSpace('My Prshe', 17);
>
> $occ_parking_spaces[] =& new ParkingSpace('Toms Caddy', 4);
>
> /*
>
> After a while a method to print all occupied spaces is necessary. Correct me
> if I'm wrong, but I usually add it to the ParkingLot class.
>
> class ParkingLot {
>
> // previous code ...
>
> var $occ_parking_spaces = array();
>
> function print_occ_spaces() {
>
> var_dump($this->occ_parking_spaces)
>
> }
>
> };
>
> What bothers me here is that I'm actually having a list of child classes in
> the parent class, is there a better/correct way to do this?
>
> I hope I made myself clear.
>
> Greetz,
>
> Yeti
>
> */
>
> ?>
>

Listen to what everyone else has said so far.  Look up IS-A versus
HAS-A.  Favor composition over inheritance.  You want your parking lot
to have spaces, but spaces don't have to be in a parking lot.

http://www.javacamp.org/moreclasses/oop/oop5.html

--- End Message ---
--- Begin Message ---
---------- Forwarded message ----------
From: Yeti <[EMAIL PROTECTED]>
Date: Fri, Jul 11, 2008 at 2:08 PM
Subject: Re: [PHP] Question regarding OO
To: Eric Butera <[EMAIL PROTECTED]>


I understand my error in thinking now.

Apple can't extend Tree.

Oak, Evergreen or Willow extend Tree.

I thank you all for helping me to understand.

On 7/11/08, Eric Butera <[EMAIL PROTECTED]> wrote:
>
> On Fri, Jul 11, 2008 at 12:03 PM, Yeti <[EMAIL PROTECTED]> wrote:
> > <?php
> >
> > /*
> >
> > I have a question here regarding object orientation in PHP and any other
> > language.
> >
> > Let's start with some hypothetical code:
> >
> > */
> >
> > // <--- 1st CLASS
> >
> > class ParkingLot {
> >
> > var size; // size in sq feet
> >
> > var max_number_of_cars; // how many cars there is space for
> >
> > function __construct($size, $max_cars) {
> >
> > $this->size = $size; $this->max_number_of_cars = $max_cars;
> >
> > }
> >
> > };
> >
> > cpark = new ParkingLot(50000, 17);
> >
> > // <--- 2nd CLASS
> >
> > class ParkingSpace extends ParkingLot {
> >
> > var ps_ID; // ID of the parking space ( 1 .. max_number_of_cars )
> >
> > var occupied_by; // ID of the car on the parking space
> >
> > var st_time; // Unix time stamp set when the car parks
> >
> > function __construct($car, $id) {
> >
> > $this->st_time = time();
> >
> > $this->occupied_by = $car;
> >
> > $this->ps_ID = $id;
> >
> > }
> >
> > };
> >
> > /*
> >
> > OK, so i got a parking lot class and its subclass parking space.
> >
> > Now the question:
> >
> > I want a list of occupied parking spaces, where do I put that? One might put
> > it into the ParkingLot Class, but wouldn't that be a recursion (a child
> > instance in the parent class)?
> >
> > */
> >
> > $occ_parking_spaces = array();
> >
> > $occ_parking_spaces[] =& new ParkingSpace('Joes Car', 8);
> >
> > $occ_parking_spaces[] =& new ParkingSpace('My Prshe', 17);
> >
> > $occ_parking_spaces[] =& new ParkingSpace('Toms Caddy', 4);
> >
> > /*
> >
> > After a while a method to print all occupied spaces is necessary. Correct me
> > if I'm wrong, but I usually add it to the ParkingLot class.
> >
> > class ParkingLot {
> >
> > // previous code ...
> >
> > var $occ_parking_spaces = array();
> >
> > function print_occ_spaces() {
> >
> > var_dump($this->occ_parking_spaces)
> >
> > }
> >
> > };
> >
> > What bothers me here is that I'm actually having a list of child classes in
> > the parent class, is there a better/correct way to do this?
> >
> > I hope I made myself clear.
> >
> > Greetz,
> >
> > Yeti
> >
> > */
> >
> > ?>
> >
>
>
> Listen to what everyone else has said so far.  Look up IS-A versus
> HAS-A.  Favor composition over inheritance.  You want your parking lot
> to have spaces, but spaces don't have to be in a parking lot.
>
> http://www.javacamp.org/moreclasses/oop/oop5.html

--- End Message ---
--- Begin Message ---
[snip]
I understand my error in thinking now.

Apple can't extend Tree.

Oak, Evergreen or Willow extend Tree.

I thank you all for helping me to understand.
[/snip]

By jove, I think he's got it!

Parking space could be a member variable of parking lot, that would make
sense.

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Jay Blanchard [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 11, 2008 1:51 PM
> To: Eric Butera; php php
> Subject: RE: [PHP] Question regarding OO
> 
> [snip]
> I understand my error in thinking now.
> 
> Apple can't extend Tree.
> 
> Oak, Evergreen or Willow extend Tree.
> 
> I thank you all for helping me to understand.
> [/snip]
> 
> By jove, I think he's got it!
> 
> Parking space could be a member variable of parking lot, that would
> make
> sense.

One thing at a time, Jay... one thing at a time. ;)


Todd Boyd
Web Programmer




--- End Message ---
--- Begin Message ---
At 12:37 PM -0400 7/11/08, Daniel Brown wrote:
On Fri, Jul 11, 2008 at 12:26 PM, Alex Chamberlain
<[EMAIL PROTECTED]> wrote:
 Ahh, but they are on different webservers....

    That's why I mentioned cURL at the very beginning, if it had to be
done as a POST request.

 At the moment, I am just using a query string. How long is the limit of the
 query string??

    There is no official limit in the protocol, but you may want to
check out Section 3.2.1 of RFC 2068 for more on that.

    The limits are in what the client is capable of sending, and what
the server is capable of receiving.  A quick S of TFW should give you
the information you need regarding PHP and the remote server's
configuration.

Incidentally, I did some minor testing on this a few years ago and found the lengths vary greatly between servers.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Fri, Jul 11, 2008 at 1:07 PM, tedd <[EMAIL PROTECTED]> wrote:
>
> Incidentally, I did some minor testing on this a few years ago and found the
> lengths vary greatly between servers.

    .... and browsers.  If I remember correctly, on Winblows alone,
Opera is capable of somewhere in the 4,500 character range, while
Internet Exploder is only capable of 2048+slack (2083 bytes).  And
pre-1.0 HTTP days, it was common for many servers not to accept more
than 255 characters on GET.

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---
--- Begin Message ---
At 1:19 PM -0400 7/11/08, Daniel Brown wrote:
On Fri, Jul 11, 2008 at 1:07 PM, tedd <[EMAIL PROTECTED]> wrote:

 Incidentally, I did some minor testing on this a few years ago and found the
 lengths vary greatly between servers.

    .... and browsers.  If I remember correctly, on Winblows alone,
Opera is capable of somewhere in the 4,500 character range, while
Internet Exploder is only capable of 2048+slack (2083 bytes).  And
pre-1.0 HTTP days, it was common for many servers not to accept more
than 255 characters on GET.


Yes, those are generally the numbers I found as well.

In my more current test, I had one test that exceeded 5000 characters, but most were in the 2000 character range.

So what it boils down to is, you can send a respectable number of characters via a GET, but if it's going to be in the 1K range, it's best to test (it's best to test anyway).

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Anyone have any ideas on this at all?

-----Original Message-----
From: Jeff Demel [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 10, 2008 10:50 AM
To: [EMAIL PROTECTED]
Subject: [PHP] cookie encoding/decoding

I have a situation where a cookie is being set elsewhere on a site by
ASP.NET, and I want to read it in my PHP.  However, when getting a cookie in
PHP, it does an automatic urldecode (or some kind of decoding).  Since the
cookie is entered in its pure form, with no encoding, on the ASP.NET side,
PHP is actually converting/decoding correct characters that don't need
decoding.  So, for example a plus sign would become a blank space.  This, of
course, means I'm getting incorrect info from the cookie.

Is there a way to turn off this PHP "feature"?  Perhaps a flag in the .ini
file?

-Jeff



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Robert Cummings [mailto:[EMAIL PROTECTED]
> Sent: Thursday, July 10, 2008 11:31 PM
> To: Boyd, Todd M.
> Cc: [EMAIL PROTECTED]
> Subject: RE: [PHP] OT - RE: [PHP] scalable web gallery
> 
> On Thu, 2008-07-10 at 12:06 -0500, Boyd, Todd M. wrote:
> > > -----Original Message-----
> > > From: Robert Cummings [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, July 10, 2008 11:24 AM
> > > To: Boyd, Todd M.
> > > Cc: Daniel Brown; [EMAIL PROTECTED]
> > > Subject: Re: [PHP] OT - RE: [PHP] scalable web gallery
> > >
> > > On Thu, 2008-07-10 at 10:18 -0500, Boyd, Todd M. wrote:
> > > > > -----Original Message-----
> > > > > From: Daniel Brown [mailto:[EMAIL PROTECTED]
> > > > > Sent: Thursday, July 10, 2008 9:42 AM
> > > > > To: paragasu
> > > > > Cc: [EMAIL PROTECTED]
> > > > > Subject: Re: [PHP] scalable web gallery
> > > >
> > > > ---8<--- snip
> > > >
> > > > >     And for the record, in the "olden days," there was a limit
> of
> > > > > about 2048 files per directory, back when no one thought there
> > > would
> > > > > ever be a need for nearly that many files.  Then, with
improved
> > > > > filesystems, the limit was rumored to be another magic number:
> > > 65535.
> > > > > That depended on the operating system, filesystem, and the
> kernel.
> > > I
> > > > > think (but don't quote me on this) that BeOS had the 65535
> limit.
> > > > >
> > > > >     Now, on an ext3 filesystem (we're not counting ReiserFS
> > because
> > > > > (1) I was never a fan, and (2) he might kill me if I say
> something
> > > > > bad!  8^O) you're okay with hundreds of thousands of files per
> > > > > directory.  ls'ing will be a bit of a pain in the ass, and if
> > > you're
> > > > > in Bash, you probably don't want to double-TAB the directory,
> but
> > > all
> > > > > in all, you'll be okay.
> > > > >
> > > > >     Still, I'd create 16 subdirectories under the images
> > directory:
> > > > > 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f.  Then name the file as an MD5
> > hash
> > > of
> > > > > the image uploaded, and place it in the directory matching the
> > > first
> > > > > character of the new file name.
> > > >
> > > > Aren't directory structures in Windows (>2.x) and even DOS
(>4.x)
> > > built
> > > > with B-Trees? I wouldn't figure there would be any kind of
> > > > limit--excepting memory, of course--to how many files or
> > > subdirectories
> > > > can be linked to a single node.
> > > >
> > > > Been a while since I've played with those underlying data
> structures
> > > we
> > > > all take for granted, though, so maybe I'm way off base.
> > >
> > > They may all be B-Trees but the storage mechanism often differs
> > between
> > > one filesystem and another. FAT16 and FAT32 both suffered from
> > > limitations on the number of files that could exist in a
directory.
> > > Actually, I may be wrong about FAT32, but I do know for certain it
> had
> > > massive slowdown if it hit some magic number.
> >
> > tedd also sent me an e-mail that sparked a memory of mine... the
> > b-trees, regardless of their efficiency, still assign each dir/file
> > INode an identifying number. This number, obviously, can only get so
> > large in the context of one b-tree object (i.e., a directory).
> >
> > In spite of this mental exercise, I do *NOT* miss my Data Structures
> &
> > Algorithms class. :)
> 
> Really? That along with distributed computing, and parallel computing
> were my favourites... and here I am programming for the Web... I guess
> it's distributed ;)

Don't get me wrong--I enjoyed the class very much. I had never seen
sorting algorithms outside of the Bubble Sort, so learning Pivot, Shell,
etc. was quite a blast. Self-balancing data trees and such were a real
eye-opener as to the power of data structures, too.

I'm just... glad I don't have to learn it all over again in a classroom
environment. :)

Haven't taken a distributed computing class just yet, but I've still got
a bit until I graduate, and these elective credits are burning a hole in
my pocket...


Todd Boyd
Web Programmer




--- End Message ---
--- Begin Message ---
At 5:01 PM -0500 7/11/08, Boyd, Todd M. wrote:
Don't get me wrong--I enjoyed the class very much. I had never seen
sorting algorithms outside of the Bubble Sort, so learning Pivot, Shell,
etc. was quite a blast.

I used to hang with a bunch of Macintosh software developers. It was brought to discussion about which sort would be best and everyone submitted theirs. I won the competition with a Quicksort. They all wow'ed about how fast it was, but I told them I didn't want to improve on it any more because I was afraid if I did, it would go back in time.

Self-balancing data trees and such were a real
eye-opener as to the power of data structures, too.

Self-balancing data trees were one of my favorites -- I even wrote a Macintosh application showing the operation of a splay binary-tree, as seen here (for those who have Macs):

http://sperling.com/freeware.php

A splay is based upon how often a search is preformed for a specific item. The more often the search, the closer the item appears toward the top of the tree -- thus less time to find it. The up and downside of the splay is that the tree is balanced each time a search is preformed -- requiring more time to balance it, but less time to find the item -- kind of a trade-off that works for some situations. I am sure that many search engines use a similar approach.

I'm just... glad I don't have to learn it all over again in a classroom
environment. :)

Not me, I would love to be in a classroom again. You would think that three degrees would burn me out, but just the opposite, I can't get enough of this stuff -- I'm constantly reading and programming everything I can lay my hands on.

The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective.

Cheers,

tedd


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective.

Cheers,

tedd



This is so true. Our Community College here in Central Oregon has a Cisco class that is based on the IOS from about 8 years ago. Some of the things that the guy teaches are not even in the current ISO. Or the work-a-rounds he talks about for problems in that ISO have already been fixed in the current releases.


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
tedd wrote:
The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective.

Cheers,

tedd



This is so true. Our Community College here in Central Oregon has a Cisco class that is based on the IOS from about 8 years ago. Some of the things that the guy teaches are not even in the current ISO. Or the work-a-rounds he talks about for problems in that ISO have already been fixed in the current releases.



...and he even calls the IOS an ISO sometimes ;-)

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
tedd wrote:
The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective.

Cheers,

tedd



This is so true. Our Community College here in Central Oregon has a Cisco class that is based on the IOS from about 8 years ago. Some of the things that the guy teaches are not even in the current ISO. Or the work-a-rounds he talks about for problems in that ISO have already been fixed in the current releases.



...and he even calls the IOS an ISO sometimes ;-)

--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
Jim Lucas wrote:
tedd wrote:
The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective.

Cheers,

tedd



This is so true. Our Community College here in Central Oregon has a Cisco class that is based on the IOS from about 8 years ago. Some of the things that the guy teaches are not even in the current ISO. Or the work-a-rounds he talks about for problems in that ISO have already been fixed in the current releases.



...and he even calls the IOS an ISO sometimes ;-)

good catch,  lazy/tired finger....  TGIF

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--- End Message ---
--- Begin Message ---
At 7:22 PM -0500 7/11/08, Shawn McKenzie wrote:
Jim Lucas wrote:
tedd wrote:
The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective.


This is so true. Our Community College here in Central Oregon has a Cisco class that is based on the IOS from about 8 years ago. Some of the things that the guy teaches are not even in the current ISO. Or the work-a-rounds he talks about for problems in that ISO have already been fixed in the current releases.


...and he even calls the IOS an ISO sometimes ;-)

He just proved his point, right?

I deal with local colleges a bit -- taught a few classes.

Recently our local Community College (LCC) decided to return to their previous database. They tried using Oracle for about six years, but they could never get it to work and finally gave up.

Unfortunately in the process, they spent over $20 million dollars, which included a help desk that cost over $650,000 per year, and everything failed miserably. They simply didn't have the experience and no one would admit that they didn't.

Instead of hiring local talent, the board of trustees sought out "experts" from NYC who encouraged them to throw even more money at the problem.

You see, NYC has all their colleges running on Oracle, but they also have over 200 full-time Oracle programmers working on it.

It wasn't until the Federal government threaten to hold up government money (because the college wasn't paying students their grant and other monies) that the college wised up and retreated from their "We're just like NYC" attitude.

Sometimes, these "smart" people aren't as smart as they think they are.

Cheers,

tedd

PS: BTW -- I offered my talents but they didn't have the professional curiosity to even reply. I'm afraid that the bad news isn't over for the local taxpayer just yet.

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
> Why not use a hash table based upon the name of the file and distribute files 
> that way?

sorry tedd, i don't really get it. but i am interested to know more
about the hash table concept.
can you explain a little bit more..

thanks..

On 7/11/08, tedd <[EMAIL PROTECTED]> wrote:
> At 10:41 AM -0400 7/10/08, Daniel Brown wrote:
>>     Still, I'd create 16 subdirectories under the images directory:
>>0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f.  Then name the file as an MD5 hash of
>>the image uploaded, and place it in the directory matching the first
>>character of the new file name.
>
> Why not use a hash table based upon the name of the file and
> distribute files that way?
>
> You don't even need a directory until you actually need one -- then
> create one 'on-the-fly' and drop the file into it.
>
> As such, it's easy to find the file again by simply hashing it's name
> -- you don't even need to store a path for the file, only the name of
> the file.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
At 8:51 AM +0800 7/12/08, paragasu wrote:
> Why not use a hash table based upon the name of the file and distribute files that way?

sorry tedd, i don't really get it. but i am interested to know more
about the hash table concept.
can you explain a little bit more..

paragasu:

A hash table is simply a result from an algorithm where you take the name of the file and produce a number from it. It can be any computation you want that produces a number -- such as just totalling the number of letters in the name.

For example, tedd.gif would compute to 4, whereas Rob.gif would be a meager 3, and Daniel.gif would be a six (which is probably over-rated for him anyway). :-)

Now, just use our respective number for storage in directories -- tedd.gif would be stored in directory 4, Ron.gif would be stored in directory 3, and Daniel.gif in directory 6.

If you store the names of the files in a database, then you don't need to store the paths as well because the paths can be computed from the file names -- do you see?

Also, you don't need to create a directory until there's actually a need for one.

This is old logic for creating memory structures where we weren't forced to allocate memory beforehand -- it's like a large array with holes in it. It's kind of slick when you can apply it to other stuff.

Now, the example I gave was pretty simple. However, a good hash algorithm is one that distributes things evenly, and that's a bit more complicated -- I'll leave that for another time.

<now returning you to your normal television viewing pleasure>  :-)

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Hey!

The client has a set of 50 images that keep rotating everyday and when a user 
clicks one of those images he is taken to that images site, in the background 
(database) i maintain a counter _for the day_ and then display the top ten 
images everyday in this format: 1-10

before the next days counter starts this data is stored in a table which has a 
simple structure like this
img_id1 int,img_id2 int  (etc till img_id10) 


Now the client wants a little extra functionality, and with me sucking at maths 
I need some help please, basically he now wants to have a chart with all the 50 
images there and showing _via percentages_ instead of the present 1-10 display 
which ones are the most popular till date.

example:
1. image name: (percentage here)
2. image name: (percentage here)
3. image name: (percentage here)
etc
any ideas on where i can start/ code tips/ urls etc would be most appreciated.
Also, if i am not mistaken there was some charting software to display this 
kind of data in pie and line charts... anybody know what i am talking about? 
because i cant find such a link in my bookmarks.

Thanks in advance,
Ryan



      

--- End Message ---
--- Begin Message ---
Ryan S wrote:
Hey!

The client has a set of 50 images that keep rotating everyday and when a user 
clicks one of those images he is taken to that images site, in the background 
(database) i maintain a counter _for the day_ and then display the top ten 
images everyday in this format: 1-10

before the next days counter starts this data is stored in a table which has a 
simple structure like this
img_id1 int,img_id2 int (etc till img_id10)

Now the client wants a little extra functionality, and with me sucking at maths 
I need some help please, basically he now wants to have a chart with all the 50 
images there and showing _via percentages_ instead of the present 1-10 display 
which ones are the most popular till date.

example:
1. image name: (percentage here)
2. image name: (percentage here)
3. image name: (percentage here)
etc
any ideas on where i can start/ code tips/ urls etc would be most appreciated.
Also, if i am not mistaken there was some charting software to display this 
kind of data in pie and line charts... anybody know what i am talking about? 
because i cant find such a link in my bookmarks.

Thanks in advance,
Ryan

percentages:
$total=img1 int + img2 int + img3 int + ....img50 int;
$perc1=(img1 int)/$total;
$perc2=(img2 int)/$total;
.
..
.
$perc50=(img50 int)/$total;

You can do it per day, per month, per year, per 28 days, per PMS cycle, per anything you want provided you have the data to do it.

Google had an pie chart thingie, check the archives of this list.

HTH,
Wolf


--- End Message ---
--- Begin Message ---
Hi,
I have a php page that asks user for a key ( or a list of keys ) and then shows a list of items matching the query.

every item in the list shows its data, and the list of keys it has ( a list of comma-separated words )

I would like to higlight, in the list of keys shown for every item, the words matching the query,

this can be easily achieved with a search and replace, for every search word, i search it in the key list and replace it adding a style tag to higlight it such as for example to have it in red color:

if ( @stripos($keylist,$keysearch!== false ) {
$keylist = str_ireplace($keysearch,'<span style="color: #FF0000">'. $keysearch.'</span>',$keylist);
}

but i have some problem with accented characters:

i have mysql with character encoding utf8, and all the php pages are declared as utf8

mysql in configured to perform queries in a case and accent insensitive way. this mean that if you search for the word 'cafe', you have returned rows that contains in the keyword list 'cafe', but also 'café' with the accent. ( I think it has to do with 'collation' settings, but I'm not investigating at the moment because it is OK for me the way it works ).

now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent- insensitive, so that i can find the word 'cafe' in a string also if it is 'café', or 'CAFÉ', or 'CAFE', and vice-versa.

hope the problem is clear and well-explained in english,

thank you for any tip,

    Giulio

--- End Message ---

Reply via email to