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:[EMAIL PROTECTED]]
> Sent: Tuesday, October 30, 2001 3:50 PM
> To:   [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to