php-general Digest 8 Oct 2010 08:00:53 -0000 Issue 6978

Topics (messages 308537 through 308557):

Re: tedd's Friday Post ($ per line)
        308537 by: Robert Cummings
        308538 by: Joshua Kehn
        308539 by: Daniel P. Brown
        308540 by: tedd
        308542 by: [email protected]
        308543 by: Joshua Kehn
        308544 by: Daniel P. Brown
        308545 by: Joshua Kehn
        308547 by: Robert Cummings
        308552 by: tedd
        308553 by: Joshua Kehn
        308554 by: Bastien Koert

Re: SEO Experts?
        308541 by: Zareef Ahmed

Class mysqli not found
        308546 by: sueandant
        308555 by: sueandant

Array / form processing
        308548 by: Ron Piggott
        308549 by: chris h
        308550 by: Ron Piggott
        308551 by: chris h
        308557 by: Sebastian Detert

zip and mac safari
        308556 by: M. Reuter

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 10-10-07 01:20 PM, tedd wrote:
Hi gang:

Several years ago I was involved in a court case where a programmers
work was being evaluated to establish a dollar amount for the work
done.

The case was a dispute where the client wanted money back from a
programmer for a discontinued project. The programmer simply wanted
to be paid for the work he had done. This wasn't a case where anyone
had done anything wrong, but rather a circumstance where two parties
were trying to figure out who was due what.

You see, the original client had been taken over by another company
who put a halt to the project the programmer was working on. The new
company claimed that because the project wasn't finished, then the
programmer should pay back all the money he was paid up-front to
start the project. However, while the project had not been finished,
the programmer had indeed worked on the project for several months.

The programmer stated he wanted to paid his hourly rate. But the new
client stated that the up-front money paid had been based upon a bid
and not an hourly rate. So, they were at odds as to what to do.

The solution in this case was to place a dollar amount on the actual
"lines of code" the programmer wrote. In other words, they took all
of programmers code and actually counted the lines of code he wrote
and then agreed to a specific dollar amount to each line. In this
case, the programmer had written over 25,000 lines of code. What do
you think he was paid?

And with all of that said, what dollar amount would you place on your
"line of code"?

This is a poor system for evaluation. Some lines are worth MUCH, MUCH more than others.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
I'm not sure this is even worth answering.

The question isn't how many lines of code were written but percentage of the 
project completed. If he estimated 8 months, worked for 4 months, and was 50% 
done, he should get half his estimate. Hourly rates wouldn't come into it 
unless the client thought it would be cheaper to simply pay him for his time 
rather then the bid. 

Subject the following to my poor legal knowledge:

I would also guess that if he was under contract with a company to provide a 
product for a set dollar amount then wouldn't the company be forced to complete 
it's half so to speak?

Regards,

-Josh
____________________________________
Joshua Kehn | [email protected]
http://joshuakehn.com

On Oct 7, 2010, at 1:20 PM, tedd wrote:

> Hi gang:
> 
> Several years ago I was involved in a court case where a programmers work was 
> being evaluated to establish a dollar amount for the work done.
> 
> The case was a dispute where the client wanted money back from a programmer 
> for a discontinued project. The programmer simply wanted to be paid for the 
> work he had done. This wasn't a case where anyone had done anything wrong, 
> but rather a circumstance where two parties were trying to figure out who was 
> due what.
> 
> You see, the original client had been taken over by another company who put a 
> halt to the project the programmer was working on. The new company claimed 
> that because the project wasn't finished, then the programmer should pay back 
> all the money he was paid up-front to start the project. However, while the 
> project had not been finished, the programmer had indeed worked on the 
> project for several months.
> 
> The programmer stated he wanted to paid his hourly rate. But the new client 
> stated that the up-front money paid had been based upon a bid and not an 
> hourly rate. So, they were at odds as to what to do.
> 
> The solution in this case was to place a dollar amount on the actual "lines 
> of code" the programmer wrote. In other words, they took all of programmers 
> code and actually counted the lines of code he wrote and then agreed to a 
> specific dollar amount to each line. In this case, the programmer had written 
> over 25,000 lines of code. What do you think he was paid?
> 
> And with all of that said, what dollar amount would you place on your "line 
> of code"?
> 
> Cheers,
> 
> tedd
> 
> -- 
> -------
> http://sperling.com/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
On Thu, Oct 7, 2010 at 13:20, tedd <[email protected]> wrote:
> Hi gang:

    Hi, Tedd!

    What's it like over there in Australia, where it's already Friday?  ;-P

-- 
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

--- End Message ---
--- Begin Message ---
At 1:30 PM -0400 10/7/10, Daniel P. Brown wrote:
On Thu, Oct 7, 2010 at 13:20, tedd <[email protected]> wrote:
 Hi gang:

    Hi, Tedd!

    What's it like over there in Australia, where it's already Friday?  ;-P

--
</Daniel P. Brown>


LOL

I'm sorry -- I seldom know what day it is. I honestly thought it was Friday. So much for me knowing what's going on, huh? That's one of the dangers of working for yourself, you seldom realize what day today is.

When I used to visit the mall (I don't now), some days I would say "Gee, it's really crowded today" and my wife would answer "Certainly, it's Saturday."

Cheers,

tedd

--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
Surely it would have been a bit more sensible to work out the time the 
programmer had spent on the project and then calculate it as a percentage of 
the total time that programmer would spend on it to complete it (which might 
not be the whole duration of the project)

Also, counting code lines seems unfair. I know it used to be this way, but its 
a bit like paying firemen based on the number of fires they put out; don't be 
surprised if arson figures go up!

I would guess though that this fellow likely had to pay some of that initial 
outlay of cash back though, and would further assume the total price attributed 
to each line was no more than 3 or 4 cents (damb English androids don't have 
the cent character)

Thanks,
Ash
http://www.ashleysheridan.co.uk

----- Reply message -----
From: "tedd" <[email protected]>
Date: Thu, Oct 7, 2010 18:20
Subject: [PHP] tedd's Friday Post ($ per line)
To: <[email protected]>

Hi gang:

Several years ago I was involved in a court case where a programmers 
work was being evaluated to establish a dollar amount for the work 
done.

The case was a dispute where the client wanted money back from a 
programmer for a discontinued project. The programmer simply wanted 
to be paid for the work he had done. This wasn't a case where anyone 
had done anything wrong, but rather a circumstance where two parties 
were trying to figure out who was due what.

You see, the original client had been taken over by another company 
who put a halt to the project the programmer was working on. The new 
company claimed that because the project wasn't finished, then the 
programmer should pay back all the money he was paid up-front to 
start the project. However, while the project had not been finished, 
the programmer had indeed worked on the project for several months.

The programmer stated he wanted to paid his hourly rate. But the new 
client stated that the up-front money paid had been based upon a bid 
and not an hourly rate. So, they were at odds as to what to do.

The solution in this case was to place a dollar amount on the actual 
"lines of code" the programmer wrote. In other words, they took all 
of programmers code and actually counted the lines of code he wrote 
and then agreed to a specific dollar amount to each line. In this 
case, the programmer had written over 25,000 lines of code. What do 
you think he was paid?

And with all of that said, what dollar amount would you place on your 
"line of code"?

Cheers,

tedd

-- 
-------
http://sperling.com/

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


--- End Message ---
--- Begin Message ---
In the case payment does come down to lines of code written I'm already covered.

if( count > 5)
{
    /* Bracing Style
}

Regards,

-Josh
____________________________________
Joshua Kehn | [email protected]
http://joshuakehn.com

On Oct 7, 2010, at 1:50 PM, [email protected] wrote:

> Surely it would have been a bit more sensible to work out the time the 
> programmer had spent on the project and then calculate it as a percentage of 
> the total time that programmer would spend on it to complete it (which might 
> not be the whole duration of the project)
> 
> Also, counting code lines seems unfair. I know it used to be this way, but 
> its a bit like paying firemen based on the number of fires they put out; 
> don't be surprised if arson figures go up!
> 
> I would guess though that this fellow likely had to pay some of that initial 
> outlay of cash back though, and would further assume the total price 
> attributed to each line was no more than 3 or 4 cents (damb English androids 
> don't have the cent character)
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> ----- Reply message -----
> From: "tedd" <[email protected]>
> Date: Thu, Oct 7, 2010 18:20
> Subject: [PHP] tedd's Friday Post ($ per line)
> To: <[email protected]>
> 
> Hi gang:
> 
> Several years ago I was involved in a court case where a programmers 
> work was being evaluated to establish a dollar amount for the work 
> done.
> 
> The case was a dispute where the client wanted money back from a 
> programmer for a discontinued project. The programmer simply wanted 
> to be paid for the work he had done. This wasn't a case where anyone 
> had done anything wrong, but rather a circumstance where two parties 
> were trying to figure out who was due what.
> 
> You see, the original client had been taken over by another company 
> who put a halt to the project the programmer was working on. The new 
> company claimed that because the project wasn't finished, then the 
> programmer should pay back all the money he was paid up-front to 
> start the project. However, while the project had not been finished, 
> the programmer had indeed worked on the project for several months.
> 
> The programmer stated he wanted to paid his hourly rate. But the new 
> client stated that the up-front money paid had been based upon a bid 
> and not an hourly rate. So, they were at odds as to what to do.
> 
> The solution in this case was to place a dollar amount on the actual 
> "lines of code" the programmer wrote. In other words, they took all 
> of programmers code and actually counted the lines of code he wrote 
> and then agreed to a specific dollar amount to each line. In this 
> case, the programmer had written over 25,000 lines of code. What do 
> you think he was paid?
> 
> And with all of that said, what dollar amount would you place on your 
> "line of code"?
> 
> Cheers,
> 
> tedd
> 
> -- 
> -------
> http://sperling.com/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
On Thu, Oct 7, 2010 at 14:04, Joshua Kehn <[email protected]> wrote:
> In the case payment does come down to lines of code written I'm already 
> covered.
>
> if( count > 5)
> {
>    /* Bracing Style
> }

    PHP Notice:  Use of undefined constant count - assumed 'count' on line 1
    PHP Warning:  Unterminated comment starting line 3 on line 3
    PHP Parse error:  syntax error, unexpected $end on line 4

-- 
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

--- End Message ---
--- Begin Message ---
I guess that's what I get for spending the last four weeks developing with 
JavaScript and Node.js.....

Regards,

-Josh
____________________________________
Joshua Kehn | [email protected]
http://joshuakehn.com

On Oct 7, 2010, at 2:09 PM, Daniel P. Brown wrote:

> On Thu, Oct 7, 2010 at 14:04, Joshua Kehn <[email protected]> wrote:
>> In the case payment does come down to lines of code written I'm already 
>> covered.
>> 
>> if( count > 5)
>> {
>>    /* Bracing Style
>> }
> 
>    PHP Notice:  Use of undefined constant count - assumed 'count' on line 1
>    PHP Warning:  Unterminated comment starting line 3 on line 3
>    PHP Parse error:  syntax error, unexpected $end on line 4
> 
> -- 
> </Daniel P. Brown>
> Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
> (866-) 725-4321
> http://www.parasane.net/


--- End Message ---
--- Begin Message ---
On 10-10-07 02:04 PM, Joshua Kehn wrote:
In the case payment does come down to lines of code written I'm already covered.

if( count>  5)
{
     /* Bracing Style
}

I hope your $count var is being incremented properly under this model:

<?php

function increment( &$count )
{
    $count = 0;
    if( $count == 0 )
    {
        $count = 1;
    }
    else
    if( $count == 1 )
    {
        $count = 2;
    }
    else
    if( $count == 2 )
    {
        $count = 3;
    }
    else
    if( $count == 3 )
    {
        $count = 4;
    }
    else
    if( $count == 4 )
    {
        $count = 5;
    }
    else
    {
        throw new Exception( 'Increment out of bounds' );
    }
}

?>

Just think how much money could be made if you need to support large datasets!!! CHAAAAAAAAAAAAAA-CHING!

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
At 6:50 PM +0100 10/7/10, [email protected] wrote:
Surely it would have been a bit more sensible to work out the time the programmer had spent on the project and then calculate it as a percentage of the total time that programmer would spend on it to complete it (which might not be the whole duration of the project)

Also, counting code lines seems unfair. I know it used to be this way, but its a bit like paying firemen based on the number of fires they put out; don't be surprised if arson figures go up!

I would guess though that this fellow likely had to pay some of that initial outlay of cash back though, and would further assume the total price attributed to each line was no more than 3 or 4 cents (damb English androids don't have the cent character)

Thanks,
Ash

As I said, this was a case that I worked on several years ago (20+). I was not the programmer, but rather a consultant for an attorney.

The programmer wanted to have his payment based upon the hours he put it, but the client wanted proof of the programmers effort. Both were understandable positions.

Considering that the programmers effort did not work, and there were no time clocks showing the actual hours the programmer worked, the solution centered on an evaluation of the end-product. That evaluation reduced to the amount of code written, which boiled down to lines of code.

Granted, as Rob said, some lines are worth more than others, but overall a case was made to pay a certain amount per line.

Now, back to the question at hand -- what price would you sell a line of your code for?

Cheers,

tedd


--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
$100 a line.

If you want more then one line let's meet and go over the project. I might give 
a significant discount.

Regards,

-Josh
____________________________________
Joshua Kehn | [email protected]
http://joshuakehn.com

On Oct 7, 2010, at 4:51 PM, tedd wrote:

> At 6:50 PM +0100 10/7/10, [email protected] wrote:
>> Surely it would have been a bit more sensible to work out the time the 
>> programmer had spent on the project and then calculate it as a percentage of 
>> the total time that programmer would spend on it to complete it (which might 
>> not be the whole duration of the project)
>> 
>> Also, counting code lines seems unfair. I know it used to be this way, but 
>> its a bit like paying firemen based on the number of fires they put out; 
>> don't be surprised if arson figures go up!
>> 
>> I would guess though that this fellow likely had to pay some of that initial 
>> outlay of cash back though, and would further assume the total price 
>> attributed to each line was no more than 3 or 4 cents (damb English androids 
>> don't have the cent character)
>> 
>> Thanks,
>> Ash
> 
> As I said, this was a case that I worked on several years ago (20+). I was 
> not the programmer, but rather a consultant for an attorney.
> 
> The programmer wanted to have his payment based upon the hours he put it, but 
> the client wanted proof of the programmers effort. Both were understandable 
> positions.
> 
> Considering that the programmers effort did not work, and there were no time 
> clocks showing the actual hours the programmer worked, the solution centered 
> on an evaluation of the end-product. That evaluation reduced to the amount of 
> code written, which boiled down to lines of code.
> 
> Granted, as Rob said, some lines are worth more than others, but overall a 
> case was made to pay a certain amount per line.
> 
> Now, back to the question at hand -- what price would you sell a line of your 
> code for?
> 
> Cheers,
> 
> tedd
> 
> 
> -- 
> -------
> http://sperling.com/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
On Thu, Oct 7, 2010 at 4:51 PM, tedd <[email protected]> wrote:
> At 6:50 PM +0100 10/7/10, [email protected] wrote:
>>
>> Surely it would have been a bit more sensible to work out the time the
>> programmer had spent on the project and then calculate it as a percentage of
>> the total time that programmer would spend on it to complete it (which might
>> not be the whole duration of the project)
>>
>> Also, counting code lines seems unfair. I know it used to be this way, but
>> its a bit like paying firemen based on the number of fires they put out;
>> don't be surprised if arson figures go up!
>>
>> I would guess though that this fellow likely had to pay some of that
>> initial outlay of cash back though, and would further assume the total price
>> attributed to each line was no more than 3 or 4 cents (damb English androids
>> don't have the cent character)
>>
>> Thanks,
>> Ash
>
> As I said, this was a case that I worked on several years ago (20+). I was
> not the programmer, but rather a consultant for an attorney.
>
> The programmer wanted to have his payment based upon the hours he put it,
> but the client wanted proof of the programmers effort. Both were
> understandable positions.
>
> Considering that the programmers effort did not work, and there were no time
> clocks showing the actual hours the programmer worked, the solution centered
> on an evaluation of the end-product. That evaluation reduced to the amount
> of code written, which boiled down to lines of code.
>
> Granted, as Rob said, some lines are worth more than others, but overall a
> case was made to pay a certain amount per line.
>
> Now, back to the question at hand -- what price would you sell a line of
> your code for?
>
> Cheers,
>
> tedd
>
>
> --
> -------
> http://sperling.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
<Dr Evil Laugh>
One Beelyon Dollars

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
A good thread and really good answers/posts are coming but in my humble
opinion this topic does not suit php-general list or atleast we should focus
on the points where php can play a role :)

On M, buton, Sep 27, 2010 at 12:54 PM, <[email protected]> wrote:

>
> > On 9/26/2010 8:09 AM, David Mehler wrote:
> >> Hello,
> >> Do we have any SEO experts on this list? I'm not one, learning only,
> >> reading a book and a few articles/tutorials from webmasters, and I'm
> >> wanting to optimize an existing site to get the best search rank
> >> possible. Some techniques, dos and don'ts would be appreciated.
> >> Thanks.
> >> Dave.
>
> Sure, it's what I do.
>
> Well first you need to work out which keyphrases to optimise for, and
> that's not obvious. Search Google for "keyword tool external" to find a
> Google tool that tells you something about the demand for a phrase and the
> competition for it.
>
> What you are trying to find are phrases that a) are very very relevant to
> your client, b) have lots of demand traffic, and c) don't have too much
> competition.
>
> The other thing to check is whether anyone else is making money at your
> selected phrases, so search for them in Google and see if people are
> advertising.
>
> Then group your phrases: so "wet dog" becomes a keyphrase group that
> includes phrases like "getting rid of wet dog smell", "avoiding wet dog
> shake" and so on.
>
> You are building a site to satisfy the keyphrase groups you've identified,
> so then one way or another you want a "wet dog" page that's optimised for
> that phrase, which means you mention "wet dog" a few times especially in
> the headline and page title and don't mention lots of other things.
>
> Then you want some links from other people's pages, Twitter, Delicious,
> YouTube and so on to your wet dog page, preferably text links that include
> the phrase "wet dog".
>
> Then you watch your Analytics data to check that people who arrive on your
> site are satisfied and covert into sales (or signups or whatever you are
> doing). If not, you run a Google Website Optimizer test to improve things
> like your headline, photos and so on.
>
> If you like, run through http://www.flowmarketing.co.uk and fill in the
> form where you get stuck. It's obviously a work in progress :-) and I'll
> complete the page that you end up at.
>
> By all means email me the website and I can be more specific.
>
> Good luck :-)
>
> Cheers
> J
> http://www.johnallsopp.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Zareef Ahmed
http://www.zareef.net

--- End Message ---
--- Begin Message ---
Is it possible that the problem is caused by my using the thread safe version 
of the PHP download binaries?

--- End Message ---
--- Begin Message ---
Hi Steve

I've uninstalled PHP5.3.3 and re-installed PHP5.2.14. Everything now works!

Best wishes and thanks to everyone for their help and input.

tholland
----- Original Message ----- From: "Steve Staples" <[email protected]>
To: "sueandant" <[email protected]>
Cc: "PHP" <[email protected]>
Sent: Wednesday, October 06, 2010 9:09 PM
Subject: Re: [PHP] Class mysqli not found


On Wed, 2010-10-06 at 21:00 +0100, sueandant wrote:
I'm still fighting a losing battle in my attempts to get PHP speak to mysqli. I can access MySql via the prompt. Apache and PHP are installed and working. In Apache's config file PHPIniDir is set to "C:\php", which is where I unzipped the binary download files, and set LoadModule php5_module C:\php\php5apache2_2.dll. In php.ini I have uncommented the mysql.dll and mysqli.dll extensions and set extension_dir = "C:\php\ext\". I have edited the environment variables to include C:\php and C:php\ext.

I am running Vista Home Premium 32 bit with SP2, Apache 2.2, PHP 5.3.3 and MySql Server 5.1.

What have I missed?

How are you connecting to the mysql?  What does your connection string
look like from your php file?  Can you cut and paste it here for us to
trouble shoot (if it is the apache->php->mysql connection problem)


Steve



--- End Message ---
--- Begin Message ---
I am writing a custom shopping cart that eventually the "cart" will be
uploaded to PayPal for payment.  I need to be able to include the option
that the purchase is a gift certificate.



At present my "add to cart" function goes like this:

===
# Gift Certificate: 1 is a gift; 2 is personal use

if ( $gift_certificate == "yes" ) {
        $gift = 1;
} else {
        $gift = 2;
}

$_SESSION['life_coaching_order'][$product][$gift]['quantity'] = 
$_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
===

Now I need to display the shopping cart contents.  I want to do this
through an array as the contents of the shopping cart are in a session
variable.  I start displaying the shopping cart contents by a "FOREACH"
loop:

===
foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference
=> $value ) {
===

What I need help with is that I don't know how to test the value of $gift
in the above array if it is a 1 or 2 (which symbolizes this is a gift
certificate).

I have something like this in mind:
if ( $_SESSION['life_coaching_order'] == 2 ) {

But I don't know how to access all the components of the array while I am
going through the FOREACH loop.

By using a "1" or "2" I have made gift certificates their own product.  If
you a better method I could use please provide me with this feedback.

Ron

The Verse of the Day
Encouragement from God's Word
www.TheVerseOfTheDay.info


--- End Message ---
--- Begin Message ---
$_SESSION['life_coaching_order'][$product][$gift]['quantity'] =
$_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
===

...

===
foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference
=> $value ) {
===


In this example $value would be an array. To test if it is a gift or not you
would do this from within the foreach loop:

//gift
if ( isset($value[1]) && isset($value[1]['quantity']) )
{
  $gift_quantity = $value[1]['quantity'];
}

//personal use
if ( isset($value[2]) && isset($value[2]['quantity']) )
{
  $personal_quantity = $value[2]['quantity'];
}


Technically the above IF's are optional, but they are proper syntax.

I don't know how you are with OOP, but you may have more luck using objects
instead of a complex array.

Chris H.


On Thu, Oct 7, 2010 at 3:35 PM, Ron Piggott
<[email protected]>wrote:

>
> I am writing a custom shopping cart that eventually the "cart" will be
> uploaded to PayPal for payment.  I need to be able to include the option
> that the purchase is a gift certificate.
>
>
>
> At present my "add to cart" function goes like this:
>
> ===
> # Gift Certificate: 1 is a gift; 2 is personal use
>
> if ( $gift_certificate == "yes" ) {
>        $gift = 1;
> } else {
>        $gift = 2;
> }
>
> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] =
> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
> ===
>
> Now I need to display the shopping cart contents.  I want to do this
> through an array as the contents of the shopping cart are in a session
> variable.  I start displaying the shopping cart contents by a "FOREACH"
> loop:
>
> ===
> foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference
> => $value ) {
> ===
>
> What I need help with is that I don't know how to test the value of $gift
> in the above array if it is a 1 or 2 (which symbolizes this is a gift
> certificate).
>
> I have something like this in mind:
> if ( $_SESSION['life_coaching_order'] == 2 ) {
>
> But I don't know how to access all the components of the array while I am
> going through the FOREACH loop.
>
> By using a "1" or "2" I have made gift certificates their own product.  If
> you a better method I could use please provide me with this feedback.
>
> Ron
>
> The Verse of the Day
> Encouragement from God's Word
> www.TheVerseOfTheDay.info
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Many thanks, Chris.

I have one additional question about this shopping cart project.  I need
to make a submit button for the purpose of removing an item from the
shopping cart.

<input type="submit" name="submit" value="Remove" class="place_order"/>

What I am struggling with is to find an effective method for passing the
product serial number (auto_increment in the table it is stored in) so I
know which product the user is removing from their purchase.  Then I will
just unset the session variable that matches.

What are your suggestion(s)?

Thank you your help with my original question Chris.

Ron

> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] =
> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
> ===
>
> ...
>
> ===
> foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference
> => $value ) {
> ===
>
>
> In this example $value would be an array. To test if it is a gift or not
> you
> would do this from within the foreach loop:
>
> //gift
> if ( isset($value[1]) && isset($value[1]['quantity']) )
> {
>   $gift_quantity = $value[1]['quantity'];
> }
>
> //personal use
> if ( isset($value[2]) && isset($value[2]['quantity']) )
> {
>   $personal_quantity = $value[2]['quantity'];
> }
>
>
> Technically the above IF's are optional, but they are proper syntax.
>
> I don't know how you are with OOP, but you may have more luck using
> objects
> instead of a complex array.
>
> Chris H.
>
>
> On Thu, Oct 7, 2010 at 3:35 PM, Ron Piggott
> <[email protected]>wrote:
>
>>
>> I am writing a custom shopping cart that eventually the "cart" will be
>> uploaded to PayPal for payment.  I need to be able to include the option
>> that the purchase is a gift certificate.
>>
>>
>>
>> At present my "add to cart" function goes like this:
>>
>> ===
>> # Gift Certificate: 1 is a gift; 2 is personal use
>>
>> if ( $gift_certificate == "yes" ) {
>>        $gift = 1;
>> } else {
>>        $gift = 2;
>> }
>>
>> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] =
>> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
>> ===
>>
>> Now I need to display the shopping cart contents.  I want to do this
>> through an array as the contents of the shopping cart are in a session
>> variable.  I start displaying the shopping cart contents by a "FOREACH"
>> loop:
>>
>> ===
>> foreach ($_SESSION['life_coaching_order'] AS
>> $coaching_fee_theme_reference
>> => $value ) {
>> ===
>>
>> What I need help with is that I don't know how to test the value of
>> $gift
>> in the above array if it is a 1 or 2 (which symbolizes this is a gift
>> certificate).
>>
>> I have something like this in mind:
>> if ( $_SESSION['life_coaching_order'] == 2 ) {
>>
>> But I don't know how to access all the components of the array while I
>> am
>> going through the FOREACH loop.
>>
>> By using a "1" or "2" I have made gift certificates their own product.
>> If
>> you a better method I could use please provide me with this feedback.
>>
>> Ron
>>
>> The Verse of the Day
>> Encouragement from God's Word
>> www.TheVerseOfTheDay.info
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>



The Verse of the Day
Encouragement from God's Word
www.TheVerseOfTheDay.info


--- End Message ---
--- Begin Message ---
<input type="submit" name="submit" value="Remove" class="place_order"/>

I don't know what the context is like, but you may be better off just using
an entire form here with hidden fields. i.e.

<form target="..." action="...">
 <input type="hidden" name="submit" value="Remove" />
 <input type="hidden" name="product_so" value="1234" />
 <input type="submit" value="Remove" class="place_order"/>
</form>


Without knowing what else is going on in your page, and how the request is
being handled on the server, it's kind of hard to give exact advice. :)

Chris H.

--- End Message ---
--- Begin Message ---
Ron Piggott schrieb:
I am writing a custom shopping cart that eventually the "cart" will be
uploaded to PayPal for payment.  I need to be able to include the option
that the purchase is a gift certificate.



At present my "add to cart" function goes like this:

===
# Gift Certificate: 1 is a gift; 2 is personal use

if ( $gift_certificate == "yes" ) {
        $gift = 1;
} else {
        $gift = 2;
}

$_SESSION['life_coaching_order'][$product][$gift]['quantity'] = $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
===

Now I need to display the shopping cart contents.  I want to do this
through an array as the contents of the shopping cart are in a session
variable.  I start displaying the shopping cart contents by a "FOREACH"
loop:

===
foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference
=> $value ) {
===

What I need help with is that I don't know how to test the value of $gift
in the above array if it is a 1 or 2 (which symbolizes this is a gift
certificate).

I have something like this in mind:
if ( $_SESSION['life_coaching_order'] == 2 ) {

But I don't know how to access all the components of the array while I am
going through the FOREACH loop.

By using a "1" or "2" I have made gift certificates their own product.  If
you a better method I could use please provide me with this feedback.

Ron

The Verse of the Day
Encouragement from God's Word
www.TheVerseOfTheDay.info


First at all, I wouldn't use 1 or 2 for defining important informations. use something like
define('ORDER_GIFT', 1);
define('ORDER_PERSONAL',2);

If you want to check all values of your array you can use several foreach loops like

foreach ($_SESSION['life_coaching_order'] AS $coaching_product => $tmp_array)
{
 foreach ($tmp_array as $coaching_gift => $tmp_array2)
 {
   switch ($coaching_gift)
     case ORDER_GIFT: break;

     case ORDER_PERSONAL: break;
)
} }


Personally I would prefer writing a class like

class Order
{
  private $product;
  private $gift;
  private $quantity;

  const ORDER_GIFT=1;
  const ORDER_PERSONAL=2;

 function getGift() {
   return $this -> gift;
 }
}

using

$_SESSION['life_coaching_order'][] = new Order();

foreach ( $_SESSION['life_coaching_order'] as $order )
{
 switch ( $order -> getGift() )

     case ORDER_GIFT: break;

     case ORDER_PERSONAL: break;
}
I hope that will help you,

Sebastian
http://elygor.de


--- End Message ---
--- Begin Message ---
Hi,

does anyone know how to use a php script to zip a folder (with a
subfolder) so that safari can open it and not decompresses forever?

Thanks, Martin


--- End Message ---

Reply via email to