|
Posted by Anne Bos on 01/06/07 20:59
On Fri, 05 Jan 2007 15:18:20 +0100 wrote "J.O. Aho"
<user@example.net>:
>Anne Bos wrote:
>> On 5 Jan 2007 03:53:25 -0800 wrote "Captain Paralytic"
>> <paul_lautman@yahoo.com>:
>>
>>> Anne Bos wrote:
>>>
>>>> In a database about houses I want the visitor to make a choice by
>>>> typing in an address. As a result the database presents one or more
>>>> adresses according to the input. So far so good.
>>>>
>>>> However, when arriving on this page I want to present a greeting and
>>>> some instructions. So the page starts with:
>>>> <?php
>>>> if (!isset ($_POST['address'])) {echo "Welcome, Instructions etc.";}
>>>> ?>
>>>>
>>>> In spite of this I always get a list of all addresses, perfectly as I
>>>> want to present them AFTER the input.
>>>> What might I do wrong, what is it I'm overlooking?
>>>> Any suggestion is appreciated.
>>> Is the rest of the code in an "else" block, or will is execute
>>> regardless of whether $_POST['address'])) is set?
>>
>> To get rid of this situation I made an 'else' block with a code that
>> is checked when results are coming. But I thought that this should not
>> be necessary as in the beginning there should be no input is
>> POST['address']
>
>'If' don't work like that by itself, it just allows or denies something to be
>done when the program is at the if-statement. And everything after the 'if' is
>executed too. Of course you can make the program to stop inside an 'if'
>
>
><?PHP
>function testsome($something,$somethingelse) {
> if($something==$somethingelse) {
> echo "something and somethingelse are the same\n";
> return;
> }
>
> echo "something isn't somethingelse\n";
> }
>
>echo "first test: ";
> testsome(1,1);
>echo "second test: ";
> testsome(1,2);
>?>
>
>You shoudl get an output that looks like:
>first test: something and somethingelse are the same
>second test: something isn't somethingelse
>
>inside functions 'return' is a good way to stop execute things in program,
>while on your page 'exit' had been a better option.
Thank you. After all this is quite logical
[Back to original message]
|