[PHP] xml/cap problems

2010-08-21 Thread Tom Shaw
I am trying to decode and encode nws compatible cap xml. An example 
is at the bottom of this post. simplexml_load_file works fine if 
cap: is removed before processing. However, if it is not 
simplexml_load_file does not parse the file at all and 
libxml_get_errors returns no errors.


Any and all help is appreciated.

Tom

?xml version='1.0' encoding='UTF-8' standalone='yes'?
cap:alert xmlns:cap='http://www.incident.com/cap/1.0'
cap:identifierNOAA-NWS-ALERTS National 
2010-08-21T13:26:34-04:00/cap:identifier

cap:senderw-nws.webmas...@noaa.gov/cap:sender
cap:sent2010-08-21T13:26:34-04:00/cap:sent
cap:statusActual/cap:status
cap:msgTypeAlert/cap:msgType
cap:scopePublic/cap:scope
cap:note
Current Watches, Warnings and Advisories for the United States Issued 
by the National Weather Service

/cap:note
cap:referenceshttp://www.weather.gov/alerts/us.html/cap:references
cap:info
cap:categoryMet/cap:category
cap:eventna/cap:event
cap:urgencyUnknown/cap:urgency
cap:severityUnknown/cap:severity
cap:certaintyUnknown/cap:certainty
cap:headline
Current Watches, Warnings and Advisories for Alaska Issued by the 
National Weather Service

/cap:headline
cap:webhttp://www.weather.gov/alerts/us.html#ak/cap:web
/cap:info



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



RE: [PHP] Building an array, kind of?

2008-10-25 Thread Tom Shaw
Here's another easy way.

$data = array();
while ($row = ifx_fetch_row ($charge_result2, NEXT){
$data[] = $row['id'];
}
ifx_free_result ($res_id);

$comma_sep = implode(', ', array_values($data));

Thomas Shaw
[EMAIL PROTECTED]

-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 24, 2008 9:52 AM
To: PHP LIST
Subject: [PHP] Building an array, kind of?

TGIF?

Apparently my brain isn't working this Friday.

I'm trying to query my table to get the first 16 ID's.  I then want
to assign the ID's to a variable and have them comma seperated.

// My query to select the first 16 rows
$get_charges2 = SELECT FIRST 16 * FROM history WHERE id = '$id;

// Executing the query
 $charge_result2 = ifx_query ($get_charges2, $connect_id);

How would I assign the result to a variable?

For instance, say my query returns rows like:

1234
1235
1236
1237
1238
1239

How would I go about putting that in a variable to equal
1234,1235,1236,1237,1238,1239 ?


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



RE: [PHP] PHP Dev Facts

2008-10-17 Thread Tom Shaw
Here's mine.

*Procedural or OOP?*

Both, even when I'm doing procedural stuff at the very least I'll have a
classes directory/autoloader function where I have OOP API's to assist in
the design.

*Dev OS*

At home windows vista. At work Linux Slackware.

*Dev PHP Version*

PHP 5.2.5. I would run ladder versions But there's problems with the
Postgres drivers on PHP 5.2.6/7 5.3 alpha.

*Live Server OS*

Linux

*Live Server PHP Version*

5.1.2

*Which HTTP Server Software (+version)?*

Apache 2

*IDE / Dev Environment*

Zend Studio for Linux or Windows always.

*Preferred Framework(s)?*

Zend Framework R0ckz. Definitely preferred to say the least :) Cake is cool
programming wise. Usability wise I run for my life.

*Do you Unit Test?*

Not really.

*Most Used Internal PHP Class*

Pdo_mysql/pgsql. 
*Preferred OS CMS*

Joomla.

Tom Shaw
[EMAIL PROTECTED]

When one door closes, another opens; but we often look so long and so
regretfully upon the closed door that we do not see the one which has opened
for us.   Alexander Graham Bell

-Original Message-
From: Nathan Rixham [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 16, 2008 6:14 PM
To: php-general@lists.php.net
Subject: [PHP] PHP Dev Facts

Evening All,

I'd be /really/ interested to know who uses what!

*Procedural or OOP?*

*Dev OS*

*Dev PHP Version*

*Live Server OS*

*Live Server PHP Version*

*Which HTTP Server Software (+version)?*

*IDE / Dev Environment*

*Preferred Framework(s)?*

*Do you Unit Test?*

*Most Used Internal PHP Class*

*Preferred OS CMS*

*Anything else you use frequently in you're PHP'ing that's worth 
mentioning:*

ps: I'm not asking for any kind of research project, just interested and 
interested to know what's most common + might learn something/find some 
new tools/toys!

pps: will reply myself as well but if I do here it'll make your 
intertwined replies messy!

Many Regards

Nathan

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


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



[PHP] Pure PHP Templating Class/AJAX Problem

2008-10-13 Thread Tom Shaw
I use a pure templating class similar to something that I found here
http://www.talkphp.com/advanced-php-programming/2568-pure-php-template-class
.html.  My question is how do you handle AJAX requests from XMLHttpRequest
(); My class pumps out the entire page over again after the AJAX request is
made. In other words the page is displaying twice. 

 

Thanks

 

 

Tom Shaw

[EMAIL PROTECTED]

 

Common sense is the knack of seeing things as they are, and doing things as
they ought to be done. 

Harriet
http://www.coolquotes.com/categories/harriet_elizabeth_beecher_stowe.html
Elizabeth Beecher Stowe

 



RE: [PHP] How to know what current system is?

2008-10-13 Thread Tom Shaw

You can try, $_SERVER['SERVER_SOFTWARE']

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Jiang Miao
Sent: Monday, October 13, 2008 3:44 PM
To: php-general@lists.php.net
Subject: [PHP] How to know what current system is?

Is there any function do that?
when php in Linux it returns linux
in windows it returns windows

I found phpinfo(INFO_GENERAL); output the string System = Linux ubuntu 
2.6.24-19-server. but I have no idea to get that info.

Thanks
Jiang Miao


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


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



RE: [PHP] 2 Questions.

2008-09-14 Thread Tom Shaw
That's cool thanks. I agree with you too it's mankind's folly. But regarding
the db question, I got the idea from CakePHP which solves the problem of
having to prefix your columns ie user_name etc etc. I think you can use
another built in php database function num_fields() and hook into the meta
data and then you would have to manually build the information into array.
I'm not sure but I'm going to hack around with it a little and see what
happens.

Thanks Thomas

-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 14, 2008 4:50 AM
To: Tom Shaw
Cc: 'PHP General'
Subject: Re: [PHP] 2 Questions.

Tom Shaw schreef:
 -Original Message-
 From: Tom Shaw [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, September 13, 2008 9:52 PM
 To: 'Jochem Maas'
 Subject: RE: [PHP] 2 Questions.
 
 iamjochem wrote:
 
 My second question is I've designed a very simple Postgres database
 wrapper.
 The methods are exactly what you would assume to see in any db wrapper a
 pg_query, pg_fetch_array. My question is in the db wrapper, is there an
 easy
 way to always include the table name as an index in all my
pg_fetch_array
 returned results? The reason I ask is when designing my tables I'm
 delegated
 to prefixing my column names i.e. users_name instead of just name or
 forum_posts instead of just posts to make sure there's no collision.  

 have your simple wrapper do something like:

 $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1;

 with regard to generating the query. if your wrapper doesn't generate the
 SQL then you'll have to parse the given SQL and rewrite it ... good luck
 with that.
 
 I'm not sure if my wrapper is a good place for the sql but I bet it's
worth
 investigating further. I like the web site iamjokem. Im not sure if that's
a
 jokem too but I couldn't figure it out... 

it's jochem not jokem, so technically there's no joke. but you could say the
'site'
is my answer to the social grid. or maybe a reaction to all the twitter like
nonsense,
or maybe just the fact that everyone seems to think the answer is out there,
when really the only answer is 'in here'

take the red pill/door. it's the only choice ;-)

..

generating SQL is pretty easy, give a function a list of fields as an array
and a
table name (you can then build the function out to include order by and
where clause
generation. here is a very simple concept function (I wouldn't bother using
it
as is):

function genSQL($fields, $table, $where, $order)
{
$fnames = array();
foreach ($fields as $f)
$fnames[] = $tablename.'_'.$f;

return 'SELECT '.join(', ', $fnames). FROM $tablename $where
$order;
}


 I should have mentioned that I use a *normalized* database wharehousing
 pattern where each row represents a distinct item being purchased. There
 could be fifty rows corresponding to a single order transaction like what
 you would see in something like an itunes music purchase. So using the
 auto
 increment id would not work to differentiate between orders. Another user
 mentioned microtime.
 
 whoa, race car hey? let's have a race.
 
 normalized smormalized. every order related system I've looked at, built
or
 worked with made a clear distinction between an **order** and an
 **orderline**,
 all you seem to have is an order line ... who do they belong to? are you
 replicating the customer details and shipping address in each row? (if so
 I hardly call that normalized)
 
 use generators or sequences or 'auto increment ids' or whatever your DB
 calls
 it, dump the timestamp/microtime nonsense, and rework you DB schema to
 incorporate order **and** orderline entities ... and use a required
foreign
 key
 in each orderline to reference the relevant order.
 
 with regard to iTunes store, steve jobs can go shove it ... but I'll
wadger
 my soul that the guys that built it know the difference between an order
 and an order line and that they use both concepts.
 
so you understand your DB model was wrong/incomplete? and that timestamps
of any granularity should not be used as UIDs?

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


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



[PHP] 2 Questions.

2008-09-13 Thread Tom Shaw
Can anybody give me any good reasons not to use a time stamp as an order
number in my shopping cart. It seems to me that the number is guaranteed to
be random and it saves having to make an extra time column to keep track of
the order. The only small concern I have is the chance that somebody orders
at the exact same time as somebody else but the chance of that has got to be
incredibly small but possible. 

 

My second question is I've designed a very simple Postgres database wrapper.
The methods are exactly what you would assume to see in any db wrapper a
pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy
way to always include the table name as an index in all my pg_fetch_array
returned results? The reason I ask is when designing my tables I'm delegated
to prefixing my column names i.e. users_name instead of just name or
forum_posts instead of just posts to make sure there's no collision.  

 

Cheers

 

Thomas Shaw

[EMAIL PROTECTED]

 



RE: [PHP] 2 Questions.

2008-09-13 Thread Tom Shaw
I should have mentioned that I use a *normalized* database wharehousing
pattern where each row represents a distinct item being purchased. There
could be fifty rows corresponding to a single order transaction like what
you would see in something like an itunes music purchase. So using the auto
increment id would not work to differentiate between orders. Another user
mentioned microtime.

-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 13, 2008 6:06 PM
To: Tom Shaw
Cc: 'PHP General'
Subject: Re: [PHP] 2 Questions.

Tom Shaw schreef:
 Can anybody give me any good reasons not to use a time stamp as an order
 number in my shopping cart. It seems to me that the number is guaranteed
to
 be random and it saves having to make an extra time column to keep track
of
 the order. The only small concern I have is the chance that somebody
orders
 at the exact same time as somebody else but the chance of that has got to
be
 incredibly small but possible. 
 

1. order number are often *required* (for accounting purposes) to be
consecutive
2. the chance is small, yet it is there ... agravated by the fact that most
orders
are placed during a concentrated period of the day.

I have no idea what you mean by 'extra time column' and/or using it to keep
track of an order... but most DBMSs have the ability to auto store a
timestamp
into a field when the given record is created.

oh ... timestamps are hardly random.

  
 
 My second question is I've designed a very simple Postgres database
wrapper.
 The methods are exactly what you would assume to see in any db wrapper a
 pg_query, pg_fetch_array. My question is in the db wrapper, is there an
easy
 way to always include the table name as an index in all my pg_fetch_array
 returned results? The reason I ask is when designing my tables I'm
delegated
 to prefixing my column names i.e. users_name instead of just name or
 forum_posts instead of just posts to make sure there's no collision.  
 

have your simple wrapper do something like:

$sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1;

with regard to generating the query. if your wrapper doesn't generate the
SQL then you'll have to parse the given SQL and rewrite it ... good luck
with that.


 
 Cheers
 
  
 
 Thomas Shaw
 
 [EMAIL PROTECTED]
 
  
 
 


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



RE: [PHP] 2 Questions.

2008-09-13 Thread Tom Shaw
-Original Message-
From: Tom Shaw [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 13, 2008 9:52 PM
To: 'Jochem Maas'
Subject: RE: [PHP] 2 Questions.

iamjochem wrote:

 My second question is I've designed a very simple Postgres database
 wrapper.
 The methods are exactly what you would assume to see in any db wrapper a
 pg_query, pg_fetch_array. My question is in the db wrapper, is there an
 easy
 way to always include the table name as an index in all my pg_fetch_array
 returned results? The reason I ask is when designing my tables I'm
 delegated
 to prefixing my column names i.e. users_name instead of just name or
 forum_posts instead of just posts to make sure there's no collision.  

 
 have your simple wrapper do something like:
 
 $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1;
 
 with regard to generating the query. if your wrapper doesn't generate the
 SQL then you'll have to parse the given SQL and rewrite it ... good luck
 with that.

I'm not sure if my wrapper is a good place for the sql but I bet it's worth
investigating further. I like the web site iamjokem. Im not sure if that's a
jokem too but I couldn't figure it out... 

-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 13, 2008 8:35 PM
To: Tom Shaw
Cc: 'PHP General'
Subject: Re: [PHP] 2 Questions.

Tom Shaw schreef:
 I should have mentioned that I use a *normalized* database wharehousing
 pattern where each row represents a distinct item being purchased. There
 could be fifty rows corresponding to a single order transaction like what
 you would see in something like an itunes music purchase. So using the
auto
 increment id would not work to differentiate between orders. Another user
 mentioned microtime.

whoa, race car hey? let's have a race.

normalized smormalized. every order related system I've looked at, built or
worked with made a clear distinction between an **order** and an
**orderline**,
all you seem to have is an order line ... who do they belong to? are you
replicating the customer details and shipping address in each row? (if so
I hardly call that normalized)

use generators or sequences or 'auto increment ids' or whatever your DB
calls
it, dump the timestamp/microtime nonsense, and rework you DB schema to
incorporate order **and** orderline entities ... and use a required foreign
key
in each orderline to reference the relevant order.

with regard to iTunes store, steve jobs can go shove it ... but I'll wadger
my soul that the guys that built it know the difference between an order
and an order line and that they use both concepts.

 -Original Message-
 From: Jochem Maas [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, September 13, 2008 6:06 PM
 To: Tom Shaw
 Cc: 'PHP General'
 Subject: Re: [PHP] 2 Questions.
 
 Tom Shaw schreef:
 Can anybody give me any good reasons not to use a time stamp as an order
 number in my shopping cart. It seems to me that the number is guaranteed
 to
 be random and it saves having to make an extra time column to keep track
 of
 the order. The only small concern I have is the chance that somebody
 orders
 at the exact same time as somebody else but the chance of that has got to
 be
 incredibly small but possible. 

 
 1. order number are often *required* (for accounting purposes) to be
 consecutive
 2. the chance is small, yet it is there ... agravated by the fact that
most
 orders
 are placed during a concentrated period of the day.
 
 I have no idea what you mean by 'extra time column' and/or using it to
keep
 track of an order... but most DBMSs have the ability to auto store a
 timestamp
 into a field when the given record is created.
 
 oh ... timestamps are hardly random.
 
  

 My second question is I've designed a very simple Postgres database
 wrapper.
 The methods are exactly what you would assume to see in any db wrapper a
 pg_query, pg_fetch_array. My question is in the db wrapper, is there an
 easy
 way to always include the table name as an index in all my pg_fetch_array
 returned results? The reason I ask is when designing my tables I'm
 delegated
 to prefixing my column names i.e. users_name instead of just name or
 forum_posts instead of just posts to make sure there's no collision.  

 
 have your simple wrapper do something like:
 
 $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1;
 
 with regard to generating the query. if your wrapper doesn't generate the
 SQL then you'll have to parse the given SQL and rewrite it ... good luck
 with that.
 
 
 Cheers

  

 Thomas Shaw

 [EMAIL PROTECTED]

  


 
 


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


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



RE: [PHP] php image and javascript include

2008-09-13 Thread Tom Shaw
I'm a big fan of Zend Studio 5. It's pretty hard to beat considering how fast 
you can code load up the page refresh, and the editor itself is very clean plus 
it works in linux. I know a lot of people like to soft tab but I just don’t 
have the patience. Hard tabs all the way for me.

Tom Shaw
[EMAIL PROTECTED]

-Original Message-
From: Ashley Sheridan [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 13, 2008 4:36 PM
To: Børge Holen
Cc: php-general@lists.php.net
Subject: Re: [PHP] php image and javascript include

On Sat, 2008-09-13 at 23:24 +0200, Børge Holen wrote:
 On Saturday 13 September 2008 01:34:41 Ashley Sheridan wrote:
  I've never been a huge fan of Vi or Vim, but I am a fan of coding in a
  text editor, not a GUI, I just guess I prefer Kate. I know for certain
  that one thing that really bugs me about Dreamweaver is the fact that it
  has a tendency to really nerf up the spacing, and it replaces tabs with
  spaces more often than not. It's all about the tabs to space things out,
  adding spaces just makes the files bigger!
 
 Oh, thats just how you set up DW, options on indentations is througoutly 
 documented inside the preferences pane and quite a few options to go, only 
 thing that is wrong with it is the way it can't handle large projects, say 
 like more than 100 files. nevermind the filesize...
 
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
 
 -- 
 ---
 Børge Holen
 http://www.arivene.net
 
I've worked on projects like that before, but never considered DW, I
used Notepad++ instead, as I was forced to use Windows at work at the
time. I never really had any reason to try to open all the files at once
though... ;)


Ash
www.ashleysheridan.co.uk


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


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



[PHP] CSV output.

2008-09-08 Thread Tom Shaw
I'm outputting a bunch of numerical values for a spreadsheet to calculate
total sales among other things on a client shopping cart. I'm running into
problems with values that contain zeros after the decimal. If a value is
234.55 the value outputs fine to the CSV file but if the value is 234.00
only 234 shows up. Is there any way to force the zeros into the spreadsheet?


 

Thanks

 

Tom Shaw

[EMAIL PROTECTED] 



RE: [PHP] CSV output.

2008-09-08 Thread Tom Shaw
Actually that won't work I tried it. For some reason the .00 shows up when I
try to manually add a .00. I know weird. The value is in the array or string
before outputting printing to CSV. Number format does not work either. 

-Original Message-
From: Boyd, Todd M. [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 08, 2008 3:59 PM
To: Tom Shaw; php-general@lists.php.net
Subject: RE: [PHP] CSV output.

 -Original Message-
 From: Tom Shaw [mailto:[EMAIL PROTECTED]
 Sent: Monday, September 08, 2008 3:54 PM
 To: php-general@lists.php.net
 Subject: [PHP] CSV output.
 
 I'm outputting a bunch of numerical values for a spreadsheet to
 calculate
 total sales among other things on a client shopping cart. I'm running
 into
 problems with values that contain zeros after the decimal. If a value
 is
 234.55 the value outputs fine to the CSV file but if the value is
 234.00
 only 234 shows up. Is there any way to force the zeros into the
 spreadsheet?

When you say shows up, do you mean in the *.csv file itself or the
application you are using to view it? If the .00 isn't showing up in the
file itself, test to see if the number being output is a whole number.
If it is, then write .00 afterwards. (Quick and dirty, I know... but
it sounds like that's what you're trying to accomplish.)


Todd Boyd
Web Programmer




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


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



RE: [PHP] CSV output.

2008-09-08 Thread Tom Shaw
This statement _is_ correct. I see values such as 234.55, but not 234.00 in
the CSV file and when I dump the data.
55.00 will equal 55 when it should equal 55.00. 234.00 shows up as 234. The
data is fine it just simple does not show up
correctly in the CSV file.

$out
.=.$name.,.$description.,.$size.,.$stock.,.$price.,.$total_cost.
;
$out .= \n;

}

dump($out); This prints the correct data.
exit();

header(Content-type: application/vnd.ms-excel);
header(Content-Disposition: attachment; filename=inventory_report.csv);

print $out; This prints wrong.

-Original Message-
From: Eric Gorr [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 08, 2008 4:21 PM
To: PHP General
Subject: Re: [PHP] CSV output.


On Sep 8, 2008, at 5:06 PM, Tom Shaw wrote:

 Actually that won't work I tried it. For some reason the .00 shows  
 up when I
 try to manually add a .00. I know weird.

Did you mean to say that it .00 _doesn't_ show up when you try to  
manually add a .00?

 The value is in the array or string
 before outputting printing to CSV. Number format does not work either.


And just to clarify...in your .csv file, you do see values such as  
234.55, but not 234.00.

I can promise you that if you fprintf( $fp, 234.00 ), you will see  
234.00 in your file.

So, the question becomes, what _exactly_ are you doing when you are  
writing this stuff out.



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


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



[PHP] Summing array indexes.

2008-09-04 Thread Tom Shaw
Is there an easy way to loop thru the array below and add the incremented
total price indexes so the order_total_price index contains the correct sum.
Any help would be greatly appreciated.

 

 

array(5) {

  [0] = array(15) {

[order_date] = string(8) 09-01-08

[order_product_price_1] = string(5) 10.00

[order_product_price_2] = string(5) 20.00

[order_total_price] = string(0) 

  }

  [1] = array(19) {

[order_date] = string(8) 09-01-08

[order_product_price_1] = string(5) 25.00

[order_product_price_2] = string(5) 15.00

[order_total_price] = string(0) 

  }

 

Like this. 

 

array(5) {

  [0] = array(15) {

[order_date] = string(8) 09-01-08

[order_product_price_1] = string(5) 10.00

[order_product_price_2] = string(5) 20.00

[order_total_price] = string(0) 30.00

  }

  [1] = array(19) {

[order_date] = string(8) 09-01-08

[order_product_price_1] = string(5) 25.00

[order_product_price_2] = string(5) 15.00

[order_total_price] = string(0) 40.00

  }

 

Tom Shaw

 

[EMAIL PROTECTED]

 



RE: [PHP] Summing array indexes.

2008-09-04 Thread Tom Shaw
Thanks for every ones help. I just used a bunch of control structures and
issest's to add it up. Not pretty but works.

if (isset($data['order_product_amount_0'])) {
$data['order_product_total'] =
number_format($data['order_product_amount_0'], 2, '.', '');
} 
if (isset($data['order_product_amount_1'])) {
$data['order_product_total'] =
number_format($data['order_product_total'] +
$data['order_product_amount_1'], 2, '.', '');
}

-Original Message-
From: Eric Gorr [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 04, 2008 5:17 PM
To: PHP General; Tom Shaw
Subject: Re: [PHP] Summing array indexes.

Not a direct answer to your question (don't worry, I hate it when  
people do this to me too), but one thought I had was to have all of  
the products ordered as their own array.

[0] = array(15) {
   [order_date] = string(8) 09-01-08
   [order_products] = array(2) {
[0] = string(5) 10.00
[1] = string(5) 20.00
   }
   [order_total_price] = string(0) 
}

In this case, it would be trivial to write a foreach loop on the  
'order_products' array to calculate the total.


Otherwise, run a foreach over the array, looking for keys which begin  
with order_product_price_ and, when found, grab the price and add it  
to order_total_price.



On Sep 4, 2008, at 6:02 PM, Tom Shaw wrote:

 --=_NextPart_000_004B_01C90EAF.FA964EB0
 Content-Type: text/plain;
   charset=US-ASCII
 Content-Transfer-Encoding: 7bit

 Is there an easy way to loop thru the array below and add the  
 incremented
 total price indexes so the order_total_price index contains the  
 correct sum.
 Any help would be greatly appreciated.





 array(5) {

  [0] = array(15) {

[order_date] = string(8) 09-01-08

[order_product_price_1] = string(5) 10.00

[order_product_price_2] = string(5) 20.00

[order_total_price] = string(0) 

  }

  [1] = array(19) {

[order_date] = string(8) 09-01-08

[order_product_price_1] = string(5) 25.00

[order_product_price_2] = string(5) 15.00

[order_total_price] = string(0) 

  }



 Like this.



 array(5) {

  [0] = array(15) {

[order_date] = string(8) 09-01-08

[order_product_price_1] = string(5) 10.00

[order_product_price_2] = string(5) 20.00

[order_total_price] = string(0) 30.00

  }

  [1] = array(19) {

[order_date] = string(8) 09-01-08

[order_product_price_1] = string(5) 25.00

[order_product_price_2] = string(5) 15.00

[order_total_price] = string(0) 40.00

  }



 Tom Shaw



 [EMAIL PROTECTED]




 --=_NextPart_000_004B_01C90EAF.FA964EB0--



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


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



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

   )

);



[PHP] Sorting Arrays

2008-08-22 Thread Tom Shaw
I'm having a problem sorting my array and wondered if anybody had experience
sorting arrays by their values. What I need to do is resort the array below 

where the most expensive product shipping price starts at position zero no
matter how big the array is.

 

array(2) {

  [0] = array(48) {

[product_id] = string(2) 34

[product_name] = string(29) Bears Ball Cap

[product_ordered_size] = string(5) ADULT

[product_sales_price] = string(8) 11.90

[product_shipping_price] = string(4) 7.85

[product_shipping_extra] = string(4) 0.06

  }

  [1] = array(48) {

[product_id] = string(2) 37

[product_name] = string(21) Baldwin L Grand Piano

[product_ordered_size] = string(5) Grand

[product_sales_price] = string(8) 11671.90

[product_shipping_price] = string(6) 500.00

[product_shipping_extra] = string(6) 450.00

  }

 

Thanks 

 

[EMAIL PROTECTED]