Re: [PHP] Creating single row for multiple items.

2008-09-09 Thread Micah Gersten
Databases are for storing and retrieving data. :)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Ashley Sheridan wrote:
> I'm assuming because this is part of a shopping cart, so he would have
> to put the data into the database only to retrieve it again, which is a
> little bit of a waste.
>
>
>   
>

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



Re: [PHP] Creating single row for multiple items.

2008-09-09 Thread tedd

At 12:38 AM +0100 9/10/08, Ashley Sheridan wrote:

I'm assuming because this is part of a shopping cart, so he would have
to put the data into the database only to retrieve it again, which is a
little bit of a waste.



If it's a shopping cart filled with Pianos, it's going to be heavy anyway. :-)

From my perspective, there's nothing wrong with (and a lot right 
with) storing an order number in a database (orders table) with all 
the item numbers that are associated/ordered with that order. He does 
not have to repeat all the data associated with each item purchased 
(i.e., name, price, shipping, etc.). It's just the order number with 
the purchased item numbers.


At some point, he has to pull the order together, show the user what 
they are buying, take payment for the items, and fulfill the order. 
You certainly don't need a collection of arrays containing all the 
bits and pieces of the order for you to figure out where everything 
is and assemble the transaction. The process is *much* simpler to 
process as an order in a database -- my opinion.


Cheers,

tedd



As for how to do it, I'd look through the arrays you have and use
associative arrays (where the order number is the key of the array
element) and set the price if the array element is just being set (use
the isset() function for this) and increment it if it already exists.


Ash
www.ashleysheridan.co.uk

Return-path:
<[EMAIL PROTECTED]>
Envelope-to: [EMAIL PROTECTED]
Delivery-date: Wed, 10 Sep 2008 00:31:46 +0100
Received: from [216.92.131.4] (port=25033 helo=lists.php.net) by
zencphosting11.zen.co.uk with esmtp (Exim 4.68) (envelope-from
<[EMAIL PROTECTED]>) id
	1KdCgU-0003IU-E0 for [EMAIL PROTECTED]; Wed, 10 Sep 
2008 00:31:46

+0100
X-Host-Fingerprint: 216.92.131.4 lists.php.net 
Received: from [216.92.131.4] ([216.92.131.4:24918] helo=lists.php.net) by

pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id
60/B9-23799-16707C84 for <[EMAIL PROTECTED]>; Tue, 09 Sep 2008
19:31:45 -0400
Received: (qmail 95720 invoked by uid 1010); 9 Sep 2008 23:31:32 -
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
list-help: <mailto:[EMAIL PROTECTED]>
list-unsubscribe: <mailto:[EMAIL PROTECTED]>
list-post: <mailto:php-general@lists.php.net>
Delivered-To: mailing list php-general@lists.php.net
Received: (qmail 95713 invoked from network); 9 Sep 2008 23:31:31 -
Authentication-Results: pb1.pair.com [EMAIL PROTECTED];
spf=unknown; sender-id=unknown
Authentication-Results: pb1.pair.com [EMAIL PROTECTED];
sender-id=unknown
Received-SPF: unknown (pb1.pair.com: domain gmail.com does not designate
76.96.30.48 as permitted sender)
X-PHP-List-Original-Sender: [EMAIL PROTECTED]
X-Host-Fingerprint: 76.96.30.48 qmta05.emeryville.ca.mail.comcast.net 
X-Authority-Analysis: v=1.0 c=1 a=ScsBlOKGSAsA:10 a=jFRa_u9Lu-YA:10
	a=yZEG99RI:8 a=oKA0wkP2:8 a=PFFhWekO:8 
a=0jRUIoGgooorb-81zc4A:9
	a=D833IUriJyPirLy-2bwA:7 a=C1lfn_RRjP3z5y6xorFLrp8CtiYA:4 
a=h9s5Ru71U4oA:10

Mime-Version: 1.0
Message-Id: <[EMAIL PROTECTED]>
In-Reply-To: <[EMAIL PROTECTED]@tx.rr.com>
References: <[EMAIL PROTECTED]@tx.rr.com>
Date: Tue, 9 Sep 2008 19:31:23 -0400
To: 
From: tedd <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii" ; format="flowed"
Subject: Re: [PHP] Creating single row for multiple items.
Content-Transfer-Encoding: 7bit

At 10:04 PM -0600 8/31/08, Tom Shaw wrote:

My array looks very similar to this. I need to create a single row for the
items that have the same order number for CSV export.  I'd prefer to do this
PHP wise instead of SQL. But would appreciate any help I can get.

$ar = array(

   array(

 "order_id" => "34",

 "order_number" => "35Y345Y356YU3",

 "order_name" => "Steinway Grand Piano #11",

 "order_ordered_size" => "Grand",

 "order_sales_price" => "78671.90",

 "order_shipping_price" => "7.85",

 "order_shipping_extra" => "0.06",

   ),



My first question is:

$78 THOUSAND DOLLARS FOR A FRAKING PIANO ???!!!???

Now that I've composed myself.

What's wrong with use MySQL and letting it do the hard stuff?

After all, what you are attempting to do is what MySQL works best at 
-- namely pull all all the records that have the same order number. 
Why make it harder on yourself?


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



--
---
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



Re: [PHP] Creating single row for multiple items.

2008-09-09 Thread Ashley Sheridan
I'm assuming because this is part of a shopping cart, so he would have
to put the data into the database only to retrieve it again, which is a
little bit of a waste.

As for how to do it, I'd look through the arrays you have and use
associative arrays (where the order number is the key of the array
element) and set the price if the array element is just being set (use
the isset() function for this) and increment it if it already exists.


Ash
www.ashleysheridan.co.uk
--- Begin Message ---

At 10:04 PM -0600 8/31/08, Tom Shaw wrote:

My array looks very similar to this. I need to create a single row for the
items that have the same order number for CSV export.  I'd prefer to do this
PHP wise instead of SQL. But would appreciate any help I can get.

$ar = array(

   array(

 "order_id" => "34",

 "order_number" => "35Y345Y356YU3",

 "order_name" => "Steinway Grand Piano #11",

 "order_ordered_size" => "Grand",

 "order_sales_price" => "78671.90",

 "order_shipping_price" => "7.85",

 "order_shipping_extra" => "0.06",

   ),



My first question is:

$78 THOUSAND DOLLARS FOR A FRAKING PIANO ???!!!???

Now that I've composed myself.

What's wrong with use MySQL and letting it do the hard stuff?

After all, what you are attempting to do is what MySQL works best at 
-- namely pull all all the records that have the same order number. 
Why make it harder on yourself?


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 ---
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Creating single row for multiple items.

2008-09-09 Thread tedd

At 10:04 PM -0600 8/31/08, Tom Shaw wrote:

My array looks very similar to this. I need to create a single row for the
items that have the same order number for CSV export.  I'd prefer to do this
PHP wise instead of SQL. But would appreciate any help I can get.

$ar = array(

   array(

 "order_id" => "34",

 "order_number" => "35Y345Y356YU3",

 "order_name" => "Steinway Grand Piano #11",

 "order_ordered_size" => "Grand",

 "order_sales_price" => "78671.90",

 "order_shipping_price" => "7.85",

 "order_shipping_extra" => "0.06",

   ),



My first question is:

$78 THOUSAND DOLLARS FOR A FRAKING PIANO ???!!!???

Now that I've composed myself.

What's wrong with use MySQL and letting it do the hard stuff?

After all, what you are attempting to do is what MySQL works best at 
-- namely pull all all the records that have the same order number. 
Why make it harder on yourself?


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



Re: [PHP] Creating single row for multiple items.

2008-09-03 Thread Brady Mitchell


On Aug 31, 2008, at 904PM, Tom Shaw wrote:

My array looks very similar to this. I need to create a single row  
for the
items that have the same order number for CSV export.  I'd prefer to  
do this

PHP wise instead of SQL. But would appreciate any help I can get.



Please send an example of what you are trying to do. If you just want  
to put each item in the array on a single line in a csv file, this  
will do it:


$fp = fopen('file.csv', 'w');

foreach ($arr as $line) {
fputcsv($fp, $line);
}

fclose($fp);

but from your description, that doesn't sound like what you are  
looking for. If you send a sample line, we can help you better.


Brady


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



Re: [PHP] Creating single row for multiple items.

2008-09-02 Thread Diogo Neves
On Tue, Sep 2, 2008 at 7:17 PM, brian <[EMAIL PROTECTED]> wrote:

> Tom Shaw wrote:
>
>> My array looks very similar to this. I need to create a single row for the
>> items that have the same order number for CSV export.  I'd prefer to do
>> this
>> PHP wise instead of SQL. But would appreciate any help I can get.
>>
>>
>> $ar = array(
>>
>>   array(
>>
>> "order_id" => "34",
>>
>> "order_number" => "35Y345Y356YU3",
>>
>> "order_name" => "Steinway Grand Piano #11",
>>
>> "order_ordered_size" => "Grand",
>>
>> "order_sales_price" => "78671.90",
>>
>> "order_shipping_price" => "7.85",
>>
>> "order_shipping_extra" => "0.06",
>>
>>   ),
>>
>>   array(
>> ...
>>
>
> A single row of *what*? The order_ids? The order_names? Perhaps you should
> post an example of the outcome you're looking for.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> Yep, i got lost too ;)

-- 
Thanks for your attention,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt


Re: [PHP] Creating single row for multiple items.

2008-09-02 Thread brian

Tom Shaw wrote:

My array looks very similar to this. I need to create a single row for the
items that have the same order number for CSV export.  I'd prefer to do this
PHP wise instead of SQL. But would appreciate any help I can get.


$ar = array(

   array(

 "order_id" => "34",

 "order_number" => "35Y345Y356YU3",

 "order_name" => "Steinway Grand Piano #11",

 "order_ordered_size" => "Grand",

 "order_sales_price" => "78671.90",

 "order_shipping_price" => "7.85",

 "order_shipping_extra" => "0.06",

   ),

   array(
...


A single row of *what*? The order_ids? The order_names? Perhaps you 
should post an example of the outcome you're looking for.


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



Re: [PHP] Creating single row for multiple items.

2008-08-31 Thread Diogo Neves
Hi,
Check if I understood you...
You have this array and want create a csv?

On Mon, Sep 1, 2008 at 5:04 AM, Tom Shaw <[EMAIL PROTECTED]> wrote:

> My array looks very similar to this. I need to create a single row for the
> items that have the same order number for CSV export.  I'd prefer to do
> this
> PHP wise instead of SQL. But would appreciate any help I can get.
>
>
>
>
>
> $ar = array(
>
>   array(
>
> "order_id" => "34",
>
> "order_number" => "35Y345Y356YU3",
>
> "order_name" => "Steinway Grand Piano #11",
>
> "order_ordered_size" => "Grand",
>
> "order_sales_price" => "78671.90",
>
> "order_shipping_price" => "7.85",
>
> "order_shipping_extra" => "0.06",
>
>   ),
>
>   array(
>
> "order_id" => "35",
>
> "order_number" => "35Y345Y356YU3",
>
> "order_name" => "Bechstein",
>
> "order_ordered_size" => "Grand",
>
> "order_sales_price" => "11671.90",
>
> "order_shipping_price" => "51.00",
>
> "order_shipping_extra" => "450.00",
>
>   ),
>
>   array(
>
> "order_id" => "36",
>
> "order_number" => "35Y345Y356YU3",
>
> "order_name" => "Bosendorfer",
>
> "order_ordered_size" => "Grand",
>
> "order_sales_price" => "11671.90",
>
> "order_shipping_price" => "500.00",
>
> "order_shipping_extra" => "450.00",
>
>   ),
>
>   array(
>
> "order_id" => "37",
>
> "order_number" => "78973467Y3Y36",
>
> "order_name" => "Steinway Grand Piano #11",
>
> "order_ordered_size" => "Grand",
>
> "order_sales_price" => "78671.90",
>
> "order_shipping_price" => "7.85",
>
> "order_shipping_extra" => "0.06",
>
>   ),
>
>   array(
>
> "order_id" => "38",
>
> "order_number" => "78973467Y3Y36",
>
> "order_name" => "Baldwin L Grand Piano #39",
>
> "order_ordered_size" => "Grand",
>
> "order_sales_price" => "11671.90",
>
> "order_shipping_price" => "1.00",
>
> "order_shipping_extra" => "450.00",
>
>   )
>
> );
>

-- 
Thanks for your attention,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt


[PHP] Creating single row for multiple items.

2008-08-31 Thread Tom Shaw
My array looks very similar to this. I need to create a single row for the
items that have the same order number for CSV export.  I'd prefer to do this
PHP wise instead of SQL. But would appreciate any help I can get.

 

 

$ar = array(

   array(

 "order_id" => "34",

 "order_number" => "35Y345Y356YU3",

 "order_name" => "Steinway Grand Piano #11",

 "order_ordered_size" => "Grand",

 "order_sales_price" => "78671.90",

 "order_shipping_price" => "7.85",

 "order_shipping_extra" => "0.06",

   ),

   array(

 "order_id" => "35",

 "order_number" => "35Y345Y356YU3",

 "order_name" => "Bechstein",

 "order_ordered_size" => "Grand",

 "order_sales_price" => "11671.90",

 "order_shipping_price" => "51.00",

 "order_shipping_extra" => "450.00",

   ),

   array(

 "order_id" => "36",

 "order_number" => "35Y345Y356YU3",

 "order_name" => "Bosendorfer",

 "order_ordered_size" => "Grand",

 "order_sales_price" => "11671.90",

 "order_shipping_price" => "500.00",

 "order_shipping_extra" => "450.00",

   ),

   array(

 "order_id" => "37",

 "order_number" => "78973467Y3Y36",

 "order_name" => "Steinway Grand Piano #11",

 "order_ordered_size" => "Grand",

 "order_sales_price" => "78671.90",

 "order_shipping_price" => "7.85",

 "order_shipping_extra" => "0.06",

   ),

   array(

 "order_id" => "38",

 "order_number" => "78973467Y3Y36",

 "order_name" => "Baldwin L Grand Piano #39",

 "order_ordered_size" => "Grand",

 "order_sales_price" => "11671.90",

 "order_shipping_price" => "1.00",

 "order_shipping_extra" => "450.00",

   )

);