Re: [PHP] Re: Forms in PHP
May I also suggest that you rewrite your echo statements as: echo 'OPTION VALUE=donateDonate this item/OPTION'; Vastly improves legibility. or just echo OPTION VALUE=donateDonate this item/OPTION; is there any common use how it should be coded or does it really make no difference to forget the ? i'm thinking here of old version of the php-parser or old webservers which could missunderstand the code. just to improve compatibility for further projects... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Forms in PHP
Actually since everything is going to XML compliance you will not want to leave out the quotes since it is a very very structured language you could hang everything without your quotes :) Just because it works, doesn¹t mean it's the best way of doing it. Browsers try to parse html with the sloppiest coder in mind so that way they are really forgiving in code. So best practice.. Code like it's xhtml and you'll make everyone gasp and say what pretty html you have :) Rick If you're going to be able to look back on something and laugh about it, you might as well laugh about it now. - Marie Osmond From: Dave [EMAIL PROTECTED] Date: Fri, 12 Apr 2002 08:33:36 +0200 To: [EMAIL PROTECTED] Subject: Re: [PHP] Re: Forms in PHP May I also suggest that you rewrite your echo statements as: echo 'OPTION VALUE=donateDonate this item/OPTION'; Vastly improves legibility. or just echo OPTION VALUE=donateDonate this item/OPTION; is there any common use how it should be coded or does it really make no difference to forget the ? i'm thinking here of old version of the php-parser or old webservers which could missunderstand the code. just to improve compatibility for further projects... -- 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] Re: Forms in PHP
May I also suggest that you rewrite your echo statements as: echo 'OPTION VALUE=donateDonate this item/OPTION'; Vastly improves legibility. It's a problem, however, if you want to include a PHP variable in that echo statement, if you're populating a SELECT menu with a loop, for instance; $menu_options = array(A = Option 1, B = Option 2, C = Option 3); foreach(array_keys($menu_options) as $option_value){ $option_text = $menu_options[$option_value]; echo 'OPTION VALUE=$option_value$option_text/OPTION'; } would just output OPTION VALUE=$option_value$option_text/OPTION OPTION VALUE=$option_value$option_text/OPTION OPTION VALUE=$option_value$option_text/OPTION which is probably not the desired output :) You need to use double quotes for variable substitution. Unfortunately, if you want to maintain XHTML compliance the tag attributes have to be double-quoted too... echo OPTION VALUE=\$option_value\$option_text/OPTION\n; (Might as well add a \n at the end of the line for readability in the browser's 'View Source' window!) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Forms in PHP
On Fri, Apr 12, 2002 at 09:36:42AM -0700, Andrew Chase wrote: : : foreach(array_keys($menu_options) as $option_value){ : $option_text = $menu_options[$option_value]; : echo 'OPTION VALUE=$option_value$option_text/OPTION'; : } : : would just output : : OPTION VALUE=$option_value$option_text/OPTION : OPTION VALUE=$option_value$option_text/OPTION : OPTION VALUE=$option_value$option_text/OPTION : : which is probably not the desired output :) You need to use double quotes : for variable substitution. Unfortunately, if you want to maintain XHTML : compliance the tag attributes have to be double-quoted too... : : echo OPTION VALUE=\$option_value\$option_text/OPTION\n; Why stick with quotation marks? echo OPTION VALUE='$option_value'$option_text/OPTION\n; -- Eugene Lee [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Forms in PHP
On Friday 12 April 2002 09:19, Jennifer Downey wrote: Actually after the submit button is clicked it returns a blank page. Jennifer Downey [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi all, Now I have a weird problem. I am using this code and can't understand why it doesn't work. When the script is run it returns a blank page, no error or done. here it is and any help would be appreciated. if(($type == book) or ($type == weapon)){ echo form action=\$PHP_SELF\ method=\post\; echo SELECT NAME=\sort\ SIZE=\1\; echo OPTION VALUE=\shop\Put in my shop/OPTION; echo OPTION VALUE=\locker\Put into my Footlocker/OPTION; echo OPTION VALUE=\discard\Discard this item/OPTION; echo OPTION VALUE=\donate\Donate this item/OPTION; echo /SELECT; echo INPUT TYPE=\submit\ VALUE=\Do It!\submit\; You haven't given your submit button a name... if(isset($submit)) Thus this test fails and you get no output. May I also suggest that you rewrite your echo statements as: echo 'OPTION VALUE=donateDonate this item/OPTION'; Vastly improves legibility. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* It was all so different before everything changed. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php