Re: Variable in Select statement?
On Oct 1, 5:59 am, GarryJones <mor...@algonet.se> wrote:
> That looks okay, but I can not get it working...
>
> The declaration
>
> $ml_collect_ind='SELECT * FROM ml_lopp WHERE scfmnum=$scfchknum AND
> " . ((in_array(loppnum, $arr_motlopp)) . " =TRUE) ORDER BY sank,
> loppnum';
>
> Gives me the following echo
>
> SELECT * FROM ml_lopp WHERE scfmnum=$scfchknum AND " .
> ((in_array(loppnum, $arr_motlopp)) . " =TRUE) ORDER BY sank, loppnum
>
> It fails to find anything valid when the first "where" condition is
> correct and the other value is in the array,
>
> Is there something in the wrong place?
>
> All appreciated
>
> Garry Jones
> Sweden
I think you may be making a wasteful sql call. Think of it this way:
You already know something that you're using to conditionally return
row results.
>From what it looks like, you're trying to see if something is in your
array using php... if it is, you want basically it to say "if true =
true". You figure maybe if its not in the array, you'll get "if false
= true". Instead, why don't you do:
if (in_array(.......... {
// do mysql call without the in_array now.
// possibly get the return results, set our variables, etc.
}
else {
// not found in array
// print error... or set our number of rows to zero if you're using
that for your code..
}
|