php-general Digest 18 Feb 2013 11:19:25 -0000 Issue 8127

2013-02-18 Thread php-general-digest-help

php-general Digest 18 Feb 2013 11:19:25 - Issue 8127

Topics (messages 320231 through 320235):

Re: OOP to run sequential SQL queries?
320231 by: Marco Behnke
320232 by: Serge Fonville
320233 by: tamouse mailing lists

Re: webDAV/CalDAV client class experience ?
320234 by: tamouse mailing lists
320235 by: B. Aerts

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Am 17.02.13 17:00, schrieb AmirBehzad Eslami:
 Dear list,

 We have a bunch of SQL-queries, they should be executed in
 a sequential order, with a defensive programming style in mind.
I don't understand what you want?
Queries are executed sequentially or do you plan to create a
multi-process PHP application?

 We were thinking to implement the solution as Stored Procedures
 instead of a PHP solution that runs SQL queries, but an article in
 Coding Horro recommendeds to avoid SP for good reasons:

 http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html

 Now we're going to carry on in PHP, and my experience says that
 we should write the solution in a procedural-style, instead of OOP.

 Is there any benefit to use OOP in these situations?

 Please share your thoughts.

 Thanks,
 -behzad



-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature
---End Message---
---BeginMessage---
Hi,

We were thinking to implement the solution as Stored Procedures
 instead of a PHP solution that runs SQL queries, but an article in
 Coding Horro recommendeds to avoid SP for good reasons:


The article shows only one thing. that common practice should be to 'do
everything where it belongs'

If you implement this practice within your application, it becomes more
maintainable, more performant and easier to develop.

Also, to determine the styles used to write your code, is almost entirely
dependent on a few things:
* Programmer's preference
* The problem you are solving
* The standards that are commonly used in the environment you are in

Is there any benefit to use OOP in these situations?

Benefits of OOP are that it becomes easier to implement a more standardized
code structure, better match with reality, clearer code, more structure,
re-usability, and a modular design.
These can all be done in procedural code as well, the difference being you
need a different mind- and skillset.

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table


2013/2/17 Marco Behnke ma...@behnke.biz

 Am 17.02.13 17:00, schrieb AmirBehzad Eslami:
  Dear list,
 
  We have a bunch of SQL-queries, they should be executed in
  a sequential order, with a defensive programming style in mind.
 I don't understand what you want?
 Queries are executed sequentially or do you plan to create a
 multi-process PHP application?
 
  We were thinking to implement the solution as Stored Procedures
  instead of a PHP solution that runs SQL queries, but an article in
  Coding Horro recommendeds to avoid SP for good reasons:
 
 
 http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html
 
  Now we're going to carry on in PHP, and my experience says that
  we should write the solution in a procedural-style, instead of OOP.
 
  Is there any benefit to use OOP in these situations?
 
  Please share your thoughts.
 
  Thanks,
  -behzad
 


 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3

 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz

 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal

 http://www.behnke.biz



---End Message---
---BeginMessage---
On Sun, Feb 17, 2013 at 10:00 AM, AmirBehzad Eslami
behzad.esl...@gmail.com wrote:
 We have a bunch of SQL-queries, they should be executed in
 a sequential order, with a defensive programming style in mind.

 We were thinking to implement the solution as Stored Procedures
 instead of a PHP solution that runs SQL queries, but an article in
 Coding Horro recommendeds to avoid SP for good reasons:

 http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html

As has been said, everything has it's place, every tool has it's use,
but we've all used that screwdriver to both open a can of paint and
then bang on the lid with handle to get it closed again. Meaning 

php-general Digest 19 Feb 2013 00:54:12 -0000 Issue 8128

2013-02-18 Thread php-general-digest-help

php-general Digest 19 Feb 2013 00:54:12 - Issue 8128

Topics (messages 320236 through 320240):

Affordable low-fee e-commerce - DIY?
320236 by: George Langley
320237 by: Adam Richardson
320238 by: Tedd Sperling
320239 by: Larry Martell

parsing  select multiple=multiple
320240 by: John Taylor-Johnston

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Hi all. Am wanting to build a site where people can donate $1.00 but is not for 
charity or other non-profit per se. So if I use PayPal, with their 2.9% + .30 
per transaction fee, that equals .33 cents for each dollar - that's a full 
third of the amount the people would be giving. Credit cards appear to be 
similar, with some percantage and about .22 cents per transactions.
Am wondering what other options I'm missing, that won't take such a chunk out 
of the low price? Is it easy enough to code to some other API for free (or at 
least cheaper)?
Thanks.


George Langley
Interactive Developer

www.georgelangley.ca

---End Message---
---BeginMessage---
On Mon, Feb 18, 2013 at 1:26 PM, George Langley george.lang...@shaw.cawrote:

 Hi all. Am wanting to build a site where people can donate $1.00 but is
 not for charity or other non-profit per se. So if I use PayPal, with their
 2.9% + .30 per transaction fee, that equals .33 cents for each dollar -
 that's a full third of the amount the people would be giving. Credit cards
 appear to be similar, with some percantage and about .22 cents per
 transactions.
 Am wondering what other options I'm missing, that won't take such a chunk
 out of the low price? Is it easy enough to code to some other API for free
 (or at least cheaper)?
 Thanks.


Not really a PHP question, but just FYI, Paypal and other providers provide
micropayments options:
https://www.paypalobjects.com/IntegrationCenter/ic_micropayments.html

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com
---End Message---
---BeginMessage---
On Feb 18, 2013, at 1:26 PM, George Langley george.lang...@shaw.ca wrote:

 Hi all. Am wanting to build a site where people can donate $1.00 but is not 
 for charity or other non-profit per se. So if I use PayPal, with their 2.9% + 
 .30 per transaction fee, that equals .33 cents for each dollar - that's a 
 full third of the amount the people would be giving. Credit cards appear to 
 be similar, with some percantage and about .22 cents per transactions.
 Am wondering what other options I'm missing, that won't take such a chunk out 
 of the low price? Is it easy enough to code to some other API for free (or at 
 least cheaper)?
 Thanks.
 
 
 George Langley
 Interactive Developer

I don't have any problems with people paying me via PayPal -- PayPal provides a 
service and they deserve a piece of the action.

In fact, I never have problems with people donating $5 to my cause (me) via my 
site -- and it happens. For example, I had one guy donate $100.

I'm waiting for someone to better that. :-)

Cheers,

tedd

_
t...@sperling.com
http://sperling.com


---End Message---
---BeginMessage---
On Mon, Feb 18, 2013 at 1:26 PM, George Langley george.lang...@shaw.ca wrote:
 Hi all. Am wanting to build a site where people can donate $1.00 but is not 
 for charity or other non-profit per se. So if I use PayPal, with their 2.9% + 
 .30 per transaction fee, that equals .33 cents for each dollar - that's a 
 full third of the amount the people would be giving. Credit cards appear to 
 be similar, with some percantage and about .22 cents per transactions.
 Am wondering what other options I'm missing, that won't take such a chunk out 
 of the low price? Is it easy enough to code to some other API for free (or at 
 least cheaper)?

Doesn't paypal only charge when someone pays with a credit card? If
they pay out of their bank account there is no charge to the
recipient.
---End Message---
---BeginMessage---
I am capable with select name=DPRpriority. (I suppose I did it 
correctly? :p )
But I haven't the first clue how to parse a select multiple and 
multiply select name=DPRtype.

Would anyone give me a couple of clues please? :)
Thanks,
John

   Priority:
   select name=DPRpriority form=DPRform
 option value=1 ?php if ($_POST[DPRpriority] == 1) 
{echo selected;} ?1/option
 option value=2 ?php if ($_POST[DPRpriority] == 2) 
{echo selected;} ?2/option
 option value=3 ?php if ($_POST[DPRpriority] == 3) 
{echo selected;} ?3/option

 option value=4 ?php
 if (empty($_POST[DPRpriority])) {echo selected;}
 if ($_POST[DPRpriority] == 4) {echo 

Re: [PHP] webDAV/CalDAV client class experience ?

2013-02-18 Thread B. Aerts

- Adding the HTTP header Accept: */* made sure all read actions ( e.g.
GET, PROPFIND, REPORT) worked perfectly


This is interesting. The Accept header has to do with what media types
the browser will accept in return. I didn't think it had anything to
do with what operations the server/application accepts. Must go read
further


I'll have to revoke this statement, as I can't reproduce it anymore.
I noticed the DaviCal didn't use it, bu the CURL call did - and yielded 
more ( = meaningfull) results.

But, as I said, can't reproduce it.

The thing I could reproduce was that, if the request was sent to the 
default port, AND this port was included in the Host header, both GET 
and PUT yielded HTTP 404.





Only problem remaining was that PUT still isn't possible - at least not with
one of the providers. Since I used a verbatim copy of a PUT action from the
RFC, I strongly suspect the problem to be with the provider.


You've no doubt considered this already, but it might be intentional
on the provider's part. I'm not up on all the webDAV/calDAV providers;
I imagine some of them might add in additional layers of auth
(including the NOWAI layer)  just to consider themselves more secure.


Yes I did, but the following arguments should negate that consideration:
- when running OPTIONS, PUT is included in the allowed HTTP methods
- the HTTP return code from the PUT command is 301, where a security 
issue would have yielded a code in the 400 range
- I think the CalDAV spec does mention Basic auhentication, so it can't 
be anything more sophisticated
- the other provider does respond as expected (though I agree, that is 
the weakest argument: expectations != specifications )
- the provider does allow sync'ing Sunbird, iCal, ... over CalDAV, and 
that works, even entering a new event (which is a PUT action). The 
Charles debugging proxy too shows that it's only Basic authentication 
that's going up - and succeeding



I'll add the code I used for the tests.
When looking for the configuration ( Calendar URL, ...), the search term 
CalDAV provider Calendar Sunbird always did the trick for me.
( I also had to modify the Davical client class a bit - make some 
protected members public for this test code to work)



if (1)
{
   $url  = 
https://caldav.calendar.provider1.com/dav/ba_aerts/Calendar/tstCalDAV/ 
; // make sure it ends in a '/' !

   $user = usrname1@provider1.com ;
   $pwd  = *1 ;
}
else
{
   $url  = 
https://www.provider2.com/calendar/dav/usrname2@provider2.com/events/ 
;

   $user = usrname2@provider2.com ;
   $pwd = **2 ;
}

/
 * run OPTIONS test *
 /

$method = OPTIONS ;

$requestHeaders = Array(content-type = text/xml,
Depth = 1) ;

echo UL\n ;

echo LI$method request:\n ;
doCurlRequest($method, $url, $user, $pwd, , $requestHeaders) ;
doCalDAVClientRequest($method, $url, $user, $pwd, , $requestHeaders ) ;
echo /LI \n ;

echo 
\r\nLI=/LI 
\n ;


/
 * run PROPFIND test*
 /

$method = PROPFIND ;
$body = XML
D:propfind xmlns:D=DAV: xmlns:CS=http://calendarserver.org/ns/; 
xmlns:C=urn:ietf:params:xml:ns:caldav

D:prop
D:resourcetype /
D:owner /
D:current-user-principal /
D:supported-report-set /
C:supported-calendar-component-set /
CS:getctag /
/D:prop
/D:propfind
XML;

echo LI$method request:\n ;
doCurlRequest($method, $url, $user, $pwd, $body, $requestHeaders) ;
doCalDAVClientRequest($method, $url, $user, $pwd, $body, $requestHeaders ) ;

echo /LI \n ;

echo 
\r\nLI=/LI 
\n ;


/
 * run REPORT test  *
 /

$method = REPORT ;
$body = XML
?xml version=1.0 encoding=utf-8 ?
C:calendar-query xmlns:D=DAV: xmlns:C=urn:ietf:params:xml:ns:caldav
 D:prop
   C:calendar-data/
   D:getetag/
 /D:prop
 C:filter
   C:comp-filter name=VCALENDAR
 C:comp-filter name=VEVENT
   C:time-range start=20130201T01Z end=20130228T01Z/
 /C:comp-filter
   /C:comp-filter
 /C:filter
/C:calendar-query
XML;

echo LI$method request:\n ;
doCurlRequest($method, $url, $user, $pwd, $body, $requestHeaders) ;
doCalDAVClientRequest($method, $url, $user, $pwd, $body, $requestHeaders ) ;
echo /LI \n ;

echo 
\r\nLI=/LI 
\n ;


/
 * run GET test *
 /

$method   = GET ;
$icsFile  = e26443db-02d4-4bf0-a97c-c1ddbd3126df.ics ;

echo LI$method request:\n ;

// some cheating 

[PHP] Affordable low-fee e-commerce - DIY?

2013-02-18 Thread George Langley
Hi all. Am wanting to build a site where people can donate $1.00 but is not for 
charity or other non-profit per se. So if I use PayPal, with their 2.9% + .30 
per transaction fee, that equals .33 cents for each dollar - that's a full 
third of the amount the people would be giving. Credit cards appear to be 
similar, with some percantage and about .22 cents per transactions.
Am wondering what other options I'm missing, that won't take such a chunk out 
of the low price? Is it easy enough to code to some other API for free (or at 
least cheaper)?
Thanks.


George Langley
Interactive Developer

www.georgelangley.ca



Re: [PHP] Affordable low-fee e-commerce - DIY?

2013-02-18 Thread Adam Richardson
On Mon, Feb 18, 2013 at 1:26 PM, George Langley george.lang...@shaw.cawrote:

 Hi all. Am wanting to build a site where people can donate $1.00 but is
 not for charity or other non-profit per se. So if I use PayPal, with their
 2.9% + .30 per transaction fee, that equals .33 cents for each dollar -
 that's a full third of the amount the people would be giving. Credit cards
 appear to be similar, with some percantage and about .22 cents per
 transactions.
 Am wondering what other options I'm missing, that won't take such a chunk
 out of the low price? Is it easy enough to code to some other API for free
 (or at least cheaper)?
 Thanks.


Not really a PHP question, but just FYI, Paypal and other providers provide
micropayments options:
https://www.paypalobjects.com/IntegrationCenter/ic_micropayments.html

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


Re: [PHP] Affordable low-fee e-commerce - DIY?

2013-02-18 Thread Tedd Sperling
On Feb 18, 2013, at 1:26 PM, George Langley george.lang...@shaw.ca wrote:

 Hi all. Am wanting to build a site where people can donate $1.00 but is not 
 for charity or other non-profit per se. So if I use PayPal, with their 2.9% + 
 .30 per transaction fee, that equals .33 cents for each dollar - that's a 
 full third of the amount the people would be giving. Credit cards appear to 
 be similar, with some percantage and about .22 cents per transactions.
 Am wondering what other options I'm missing, that won't take such a chunk out 
 of the low price? Is it easy enough to code to some other API for free (or at 
 least cheaper)?
 Thanks.
 
 
 George Langley
 Interactive Developer

I don't have any problems with people paying me via PayPal -- PayPal provides a 
service and they deserve a piece of the action.

In fact, I never have problems with people donating $5 to my cause (me) via my 
site -- and it happens. For example, I had one guy donate $100.

I'm waiting for someone to better that. :-)

Cheers,

tedd

_
t...@sperling.com
http://sperling.com



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



Re: [PHP] Affordable low-fee e-commerce - DIY?

2013-02-18 Thread Larry Martell
On Mon, Feb 18, 2013 at 1:26 PM, George Langley george.lang...@shaw.ca wrote:
 Hi all. Am wanting to build a site where people can donate $1.00 but is not 
 for charity or other non-profit per se. So if I use PayPal, with their 2.9% + 
 .30 per transaction fee, that equals .33 cents for each dollar - that's a 
 full third of the amount the people would be giving. Credit cards appear to 
 be similar, with some percantage and about .22 cents per transactions.
 Am wondering what other options I'm missing, that won't take such a chunk out 
 of the low price? Is it easy enough to code to some other API for free (or at 
 least cheaper)?

Doesn't paypal only charge when someone pays with a credit card? If
they pay out of their bank account there is no charge to the
recipient.

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



[PHP] parsing select multiple=multiple

2013-02-18 Thread John Taylor-Johnston
I am capable with select name=DPRpriority. (I suppose I did it 
correctly? :p )
But I haven't the first clue how to parse a select multiple and 
multiply select name=DPRtype.

Would anyone give me a couple of clues please? :)
Thanks,
John

   Priority:
   select name=DPRpriority form=DPRform
 option value=1 ?php if ($_POST[DPRpriority] == 1) 
{echo selected;} ?1/option
 option value=2 ?php if ($_POST[DPRpriority] == 2) 
{echo selected;} ?2/option
 option value=3 ?php if ($_POST[DPRpriority] == 3) 
{echo selected;} ?3/option

 option value=4 ?php
 if (empty($_POST[DPRpriority])) {echo selected;}
 if ($_POST[DPRpriority] == 4) {echo selected;} 
?4/option

   /select


   select multiple=multiple name=DPRtype form=DPRform
 option value=1. Crimes Against Persons1. Crimes 
Against Persons/option

 option value=2. Disturbances2. Disturbances/option
 option value=3. Assistance / Medical3. Assistance / 
Medical/option
 option value=4. Crimes Against Property4. Crimes 
Against Property/option
 option value=5. Accidents / Traffic Problems5. 
Accidents / Traffic Problems/option
 option value=6. Suspicious Circumstances6. Suspicious 
Circumstances/option
 option value=7. Morality / Drugs7. Morality / 
Drugs/option
 option value=8. Miscellaneous Service8. Miscellaneous 
Service/option

 option value=9. Alarms9. Alarms/option
   /select


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



Re: [PHP] parsing select multiple=multiple

2013-02-18 Thread tamouse mailing lists
On Mon, Feb 18, 2013 at 6:54 PM, John Taylor-Johnston
john.taylor-johns...@cegepsherbrooke.qc.ca wrote:
 I am capable with select name=DPRpriority. (I suppose I did it
 correctly? :p )
 But I haven't the first clue how to parse a select multiple and multiply
 select name=DPRtype.
 Would anyone give me a couple of clues please? :)
 Thanks,
 John

Priority:
select name=DPRpriority form=DPRform
  option value=1 ?php if ($_POST[DPRpriority] == 1) {echo
 selected;} ?1/option
  option value=2 ?php if ($_POST[DPRpriority] == 2) {echo
 selected;} ?2/option
  option value=3 ?php if ($_POST[DPRpriority] == 3) {echo
 selected;} ?3/option
  option value=4 ?php
  if (empty($_POST[DPRpriority])) {echo selected;}
  if ($_POST[DPRpriority] == 4) {echo selected;}
 ?4/option
/select


select multiple=multiple name=DPRtype form=DPRform
  option value=1. Crimes Against Persons1. Crimes Against
 Persons/option
  option value=2. Disturbances2. Disturbances/option
  option value=3. Assistance / Medical3. Assistance /
 Medical/option
  option value=4. Crimes Against Property4. Crimes Against
 Property/option
  option value=5. Accidents / Traffic Problems5. Accidents /
 Traffic Problems/option
  option value=6. Suspicious Circumstances6. Suspicious
 Circumstances/option
  option value=7. Morality / Drugs7. Morality /
 Drugs/option
  option value=8. Miscellaneous Service8. Miscellaneous
 Service/option
  option value=9. Alarms9. Alarms/option
/select


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


Do test this, but I think all that's required is you make the name an array:

select name=DPRpriority[] form=DPRform

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



Re: [PHP] parsing select multiple=multiple

2013-02-18 Thread John Taylor-Johnston



 select multiple=multiple name=DPRtype form=DPRform
 option value=1. Crimes Against Persons1. Crimes Against
Persons/option
 option value=2. Disturbances2. Disturbances/option
 option value=3. Assistance / Medical3. Assistance /
Medical/option
 option value=4. Crimes Against Property4. Crimes Against
Property/option
 option value=5. Accidents / Traffic Problems5. Accidents /
Traffic Problems/option
 option value=6. Suspicious Circumstances6. Suspicious
Circumstances/option
 option value=7. Morality / Drugs7. Morality /
Drugs/option
 option value=8. Miscellaneous Service8. Miscellaneous
Service/option
 option value=9. Alarms9. Alarms/option
   /select





Do test this, but I think all that's required is you make the name an array:

select name=DPRpriority[] form=DPRform
  

Something like this?

if $DPRpriority[0] == 7. Morality / Drugs { echo selected; }

I hate arrays. :D

http://php.net/manual/en/language.types.array.php

?php
$DPRpriority[]  = array(
   1= a,
   1  = b,
   1.5  = c,
   true = d,
);
var_dump($array);
?



Re: [PHP] parsing select multiple=multiple

2013-02-18 Thread David Robley
tamouse mailing lists wrote:

 On Mon, Feb 18, 2013 at 6:54 PM, John Taylor-Johnston
 john.taylor-johns...@cegepsherbrooke.qc.ca wrote:
 I am capable with select name=DPRpriority. (I suppose I did it
 correctly? :p )
 But I haven't the first clue how to parse a select multiple and
 multiply select name=DPRtype.
 Would anyone give me a couple of clues please? :)
 Thanks,
 John

Priority:
select name=DPRpriority form=DPRform
  option value=1 ?php if ($_POST[DPRpriority] == 1)
  {echo
 selected;} ?1/option
  option value=2 ?php if ($_POST[DPRpriority] == 2)
  {echo
 selected;} ?2/option
  option value=3 ?php if ($_POST[DPRpriority] == 3)
  {echo
 selected;} ?3/option
  option value=4 ?php
  if (empty($_POST[DPRpriority])) {echo selected;}
  if ($_POST[DPRpriority] == 4) {echo selected;}
 ?4/option
/select


select multiple=multiple name=DPRtype form=DPRform
  option value=1. Crimes Against Persons1. Crimes Against
 Persons/option
  option value=2. Disturbances2. Disturbances/option
  option value=3. Assistance / Medical3. Assistance /
 Medical/option
  option value=4. Crimes Against Property4. Crimes Against
 Property/option
  option value=5. Accidents / Traffic Problems5. Accidents
  /
 Traffic Problems/option
  option value=6. Suspicious Circumstances6. Suspicious
 Circumstances/option
  option value=7. Morality / Drugs7. Morality /
 Drugs/option
  option value=8. Miscellaneous Service8. Miscellaneous
 Service/option
  option value=9. Alarms9. Alarms/option
/select


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

 
 Do test this, but I think all that's required is you make the name an
 array:
 
 select name=DPRpriority[] form=DPRform

More info at http://www.php.net/manual/en/language.variables.external.php 
(search for multiple) and 
http://www.php.net/manual/en/faq.html.php#faq.html.select-multiple

-- 
Cheers
David Robley

Know what I hate? I hate rhetorical questions!


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



Re: [PHP] parsing select multiple=multiple

2013-02-18 Thread tamouse mailing lists
On Mon, Feb 18, 2013 at 7:28 PM, John Taylor-Johnston
john.taylor-johns...@cegepsherbrooke.qc.ca wrote:

  select multiple=multiple name=DPRtype form=DPRform
  option value=1. Crimes Against Persons1. Crimes Against
 Persons/option
  option value=2. Disturbances2. Disturbances/option
  option value=3. Assistance / Medical3. Assistance /
 Medical/option
  option value=4. Crimes Against Property4. Crimes Against
 Property/option
  option value=5. Accidents / Traffic Problems5. Accidents
 /
 Traffic Problems/option
  option value=6. Suspicious Circumstances6. Suspicious
 Circumstances/option
  option value=7. Morality / Drugs7. Morality /
 Drugs/option
  option value=8. Miscellaneous Service8. Miscellaneous
 Service/option
  option value=9. Alarms9. Alarms/option
/select





 Do test this, but I think all that's required is you make the name an
 array:

 select name=DPRpriority[] form=DPRform


 Something like this?

 if $DPRpriority[0] == 7. Morality / Drugs { echo selected; }

 I hate arrays. :D

 http://php.net/manual/en/language.types.array.php

 ?php
 $DPRpriority[]  = array(
1= a,
1  = b,
1.5  = c,
true = d,
 );
 var_dump($array);
 ?


Not exactly that -- I think I goofed up your variable names.
$DPRpriority is the set of values that can be selected, and DPRType
are the values returned from the form.

Here's a small snippet showing how it works, I hope:

?php

// Initial value for demo
$DPRpriority = array(array('name' = Crimes Against Persons,
'selected' = false),
 array('name' = Disturbances, 'selected' = false),
 array('name' = Assistance / Medical, 'selected' = 
false),
 array('name' = Crimes Against Property, 'selected' = 
false),
 array('name' = Accidents / Traffic Problems, 'selected' 
= false),
 array('name' = Suspicious Circumstances, 'selected' = 
false),
 array('name' = Morality / Drugs, 'selected' = false),
 array('name' = Miscellaneous Service, 'selected' = 
false),
 array('name' =Alarms, 'selected' = false));

echo h1Initial value of DPRpriority:/h1ul\n;
foreach ($DPRpriority as $item = $value) {
  echo li .$item.: .$value['name']. selected:
.$value['selected']. /li\n;
}
echo /ul\n;

if (count($_POST)  0) {
  // something was posted:
  echo h1\$_POST:/h1precode\n;
  var_dump($_POST);
  echo /code/pre\n;

  echo h2Items selected:/h2ul\n;
  foreach ($_POST['DPRType'] as $item) {
$DPRpriority[$item]['selected'] = true;
echo li.$item.: .$DPRpriority[$item]['name']./li\n;
  }
  echo /ul\n;

  echo h1Final value of DPRpriority:/h1ul\n;
  foreach ($DPRpriority as $item = $value) {
echo li .$item.: .$value['name']. selected:
.$value['selected']. /li\n;
  }
  echo /ul\n;
}

?

form method=post

select name=DPRType[] id=DPRType[] multiple onchange=
size=?php echo count($DPRpriority) ?
  ?php foreach ($DPRpriority as $index = $value) { ?
option value=?php echo $index; ??php if ($value['selected'])
{echo ' selected=selected';} ??php echo
$value['name'];?/option
 ?php } ?
/select

input type=submit name=submit value=submit /

/form


(gist link: https://gist.github.com/tamouse/4982630 )

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