php-general Digest 19 Feb 2013 20:44:43 -0000 Issue 8129
php-general Digest 19 Feb 2013 20:44:43 - Issue 8129 Topics (messages 320241 through 320245): Re: parsing select multiple=multiple 320241 by: tamouse mailing lists 320242 by: John Taylor-Johnston 320243 by: David Robley 320244 by: tamouse mailing lists 320245 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--- 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 ---End Message--- ---BeginMessage--- 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); ? ---End Message--- ---BeginMessage--- 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.
Re: [PHP] parsing select multiple=multiple
tamouse mailing lists wrote: I hate arrays. :D Here's a small snippet showing how it works, I hope: foreach ($DPRpriority as $item = $value) { echo li .$item.: .$value['name']. selected: .$value['selected']. /li\n; } Question 1: when did we have to add [] to a input name to turn it into an array? input type=checkbox name=DPRlocationdetails[] value=Unknown According to phpinfo() it still comes out as $_POST['DPRlocationdetails'] without []. Are the [] necessary? -- Question 2: I was looking at some code in the Manual, where someone used isset and is_array. How necessary is if(isset($_POST['DPRlocationdetails'])) and then to use: if(is_array($_POST['DPRlocationdetails'])) That seems like over kill? -- Question 3: My code works, perfectly. In this case, I decided to attack some check-boxes first. The resulting function will work for select multiple too.. Does anyone see me doing something wrong in my code below? My questions are: Is this the only way to pass Unknown, Family Home or Apartment into the function? Is this correct? if ($_POST['DPRlocationdetails'] == Unknown) Somebody once told me I had to do it this way? if (Unknown == $_POST['DPRlocationdetails']) John snip--- form action=foo.php id=DPRform method=postinput value=Update type=submit input type=checkbox name=DPRlocationdetails[] value=Unknown ?php filter_value($_POST['DPRlocationdetails'],Unknown); ? Unknown input type=checkbox name=DPRlocationdetails[] value=Family Home ?php filter_value($_POST['DPRlocationdetails'],Family Home); ? Family Home input type=checkbox name=DPRlocationdetails[] value=Apartment ?php filter_value($_POST['DPRlocationdetails'],Apartment); ? Apartment /form ?php function filter_value($tofilter,$tofind) { foreach($tofilter as $value){ if ($value == $tofind) echo checked; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing select multiple=multiple
On 2/19/2013 2:02 PM, John Taylor-Johnston wrote: tamouse mailing lists wrote: I hate arrays. :D Here's a small snippet showing how it works, I hope: foreach ($DPRpriority as $item = $value) { echo li .$item.: .$value['name']. selected: .$value['selected']. /li\n; } Question 1: when did we have to add [] to a input name to turn it into an array? input type=checkbox name=DPRlocationdetails[] value=Unknown According to phpinfo() it still comes out as $_POST['DPRlocationdetails'] without []. Are the [] necessary? -- Question 2: I was looking at some code in the Manual, where someone used isset and is_array. How necessary is if(isset($_POST['DPRlocationdetails'])) and then to use: if(is_array($_POST['DPRlocationdetails'])) That seems like over kill? -- Question 3: My code works, perfectly. In this case, I decided to attack some check-boxes first. The resulting function will work for select multiple too.. Does anyone see me doing something wrong in my code below? My questions are: Is this the only way to pass Unknown, Family Home or Apartment into the function? Is this correct? if ($_POST['DPRlocationdetails'] == Unknown) Somebody once told me I had to do it this way? if (Unknown == $_POST['DPRlocationdetails']) John snip--- form action=foo.php id=DPRform method=postinput value=Update type=submit input type=checkbox name=DPRlocationdetails[] value=Unknown ?php filter_value($_POST['DPRlocationdetails'],Unknown); ? Unknown input type=checkbox name=DPRlocationdetails[] value=Family Home ?php filter_value($_POST['DPRlocationdetails'],Family Home); ? Family Home input type=checkbox name=DPRlocationdetails[] value=Apartment ?php filter_value($_POST['DPRlocationdetails'],Apartment); ? Apartment /form ?php function filter_value($tofilter,$tofind) { foreach($tofilter as $value){ if ($value == $tofind) echo checked; } } ? The [] are necessary if there are going to be multiple occurrences of an input with the same name, hence the [] to allow your php script to extract all of the occurrences. Using isset and is_array comes in handy to help you handle the incoming var properly. If it IS set, you then have to check if there is only one value (hence a string) or if there are multiple values (an array). #3 - no idea what you are asking. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] PHP 5.3.22RC1 and 5.4.12RC1 Released for Testing!
Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100): If no critical issues is found in this RC, the final version will be released in two weeks. Just curious: what is keeping 5.3.22 and 5.4.12 from being released? Are there any issues? Jan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] PHP 5.3.22RC1 and 5.4.12RC1 Released for Testing!
On Wed, 2013-02-20 at 00:13 +0100, Jan Ehrhardt wrote: Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100): If no critical issues is found in this RC, the final version will be released in two weeks. Just curious: what is keeping 5.3.22 and 5.4.12 from being released? Are there any issues? As a look on qa.php.net or the box on the top right of php.net tells we have RC2 for both out, you can also see in the repo that the release is being prepared: http://git.php.net/?p=php-src.git;a=blobdiff;f=NEWS;h=d3a3e9fa0f344d9b736ea17ce408df6b02e8b561;hp=c4262020de69b7a93b8fcf4923e85194756435a7;hb=0183c29cb3921926855ed6f5e7cea7851fb8a5a1;hpb=904d2202eaecb7c300c36f37ebc5503513220c09 Please test the RCs and provide test feedback. Thanks. johannes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] PHP 5.3.22RC1 and 5.4.12RC1 Released for Testing!
Hi! Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100): If no critical issues is found in this RC, the final version will be released in two weeks. Just curious: what is keeping 5.3.22 and 5.4.12 from being released? Are there any issues? We had 5.4.12 RC2 last week, due to recent SOAP fixes we had to pull in, and will have 5.4.12 GA this week. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] PHP 5.3.22RC1 and 5.4.12RC1 Released for Testing!
Stas Malyshev in php.internals (Tue, 19 Feb 2013 15:35:54 -0800): Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100): If no critical issues is found in this RC, the final version will be released in two weeks. Just curious: what is keeping 5.3.22 and 5.4.12 from being released? Are there any issues? We had 5.4.12 RC2 last week, due to recent SOAP fixes we had to pull in, and will have 5.4.12 GA this week. OK. Johannes' reply made me think I mistook the final RC for the release, but you seem to indicate there was indeed a little delay. For Johannes: building 5.3.22 and 5.4.12 (both NTS, Windows) right now. I will report back if I run into something. Jan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] phpinfo()
I cannot find button2 in phpinfo() when I click it. I was hoping to find a $_POST[button2] value. What am I doing wrong? input type=button name=button2 id=button2 value=Print Mode onclick=formSubmit() I really wanted to use a button to pass a different condition than a input type=submit -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] if (empty versus if (isset
What is the difference between? if (empty... http://www.php.net/manual/en/function.empty.php Determine whether a variable is empty and if (isset... http://php.net/manual/en/function.isset.php Determine if a variable is set and is not *|NULL|* I have an input type=radio value=something. If it is not checked, it is NOT empty, because it has a value, right? But it is NOT set, right? Is this empty, because it's value is ? input type=text value= Just trying to understand ... :)
Re: [PHP] if (empty versus if (isset
On Tue, Feb 19, 2013 at 9:29 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: What is the difference between? if (empty... http://www.php.net/manual/en/function.empty.php Determine whether a variable is empty and if (isset... http://php.net/manual/en/function.isset.php Determine if a variable is set and is not *|NULL|* I like the explanation on the empty page: No warning is generated if the variable does not exist. That means empty() is essentially the concise equivalent to !isset($var) || $var == false. I have an input type=radio value=something. If it is not checked, it is NOT empty, because it has a value, right? But it is NOT set, right? Some of the form elements (e.g., checkboxes, radio's) are a little tricky: http://stackoverflow.com/questions/476426/submit-an-html-form-with-empty-checkboxes When unchecked, no GET or POST variable is present to represent their value. Is this empty, because it's value is ? input type=text value= Just trying to understand ... :) A text field would be present in the GET or POST super globals, and if empty (the user did not add input), the empty function would return true because an empty string is one of the values that evaluates to false: - (an empty string) - 0 (0 as an integer) - 0.0 (0 as a float) - 0 (0 as a string) - NULL - FALSE - array() (an empty array) - $var; (a variable declared, but without a value) Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo()
John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I cannot find button2 in phpinfo() when I click it. I was hoping to find a $_POST[button2] value. What am I doing wrong? input type=button name=button2 id=button2 value=Print Mode onclick=formSubmit() I really wanted to use a button to pass a different condition than a input type=submit Use a different value or name on the input type=submit/ button. Don't use JavaScript to trigger the form like that. Its not necessary and will bite you in the ass if ypu get a visitor who browses without JavaScript, which can include security aware users, blind users, etc Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php