RE: [PHP-DB] What's wrong with my function? :(
| From: | NCI/IMS) | Date: | Tue, 30 Oct 2001 20:55:52 +0000 |
| Subject: | RE: [PHP-DB] What's wrong with my function? :( | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-13871@lists.php.net to get a copy of this message | ||
I'm new to PHP but one thing I think might be happening is that maybe the
changes aren't being made to a "global" (I'm a Java programmer) $sql so they
aren't being kept. Does it actually break or is it not appending the
additional string? I'd try printing out the $sql and see what you're
getting - possibly at different stages of the program - like before and
after you call your function.
Good luck!
-Natalie
> -----Original Message-----
> From: TorrentUK [SMTP:torrent@upyourpipe.com]
> Sent: Tuesday, October 30, 2001 3:50 PM
> To: php-db@lists.php.net
> Subject: [PHP-DB] What's wrong with my function? :(
>
> Please could some take a look at this code and tell me why when I take my
> IF
> statements out of the function and put in them in the same place where I
> call the function from they work, but as soon as I replace them with the
> function name they don't?
>
> Appreciate any help.
> torrent
>
> Here's the code...
>
> // Define the rating's filter
> <?php
> function RatingFilter () {
> if ($br) {$sql.= " and beg_rate >= '2'";}
>
> if ($ir) {$sql.= " and int_rate >= '2'";}
>
> if ($ar) {$sql.= " and adv_rate >= '2'";}
>
> if ($sr) {$sql.= " and sbd_rate >= '2'";}
>
> }
> ?>
>
>
> if ($search) {
>
> include ('logon-inc.php');
>
> $sql = "SELECT rsrt_name, ctry_name FROM resort_tbl WHERE
> ctry_name='$country[0]'";
>
> RatingFilter(); <--- If I put 'if' statement here instead it works
>
>
> for ($n=1; count($country) > $n; $n++){
>
> $sql.= " or ctry_name='$country[$n]'";
>
> RatingFilter(); <-- Or here
> }
> .
> .
> .
> .
> }
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net