Variable in Select statement?
I am writing a mysql select statement in php and I would like to
include a variable in it but cant grasp the syntax.
// Example
What I want to do
if ($forma == "mot" ) {
$fishnet = "(1,2,3,4)";
} else {
$fishnet = "(3,4,7)";
}
$ml_collect='SELECT * FROM ml_lopp WHERE ml_lopp.sank IN $fishnet
ORDER BY date1, ml_lopp.loppnum';
..... returns no rows. However the code itself with manually inserted
values...
$ml_collect='SELECT * FROM ml_lopp WHERE ml_lopp.sank IN (1,2,3,4)
ORDER BY date1, ml_lopp.loppnum';
.....and.....
$ml_collect='SELECT * FROM ml_lopp WHERE ml_lopp.sank IN (3,4,7) ORDER
BY date1, ml_lopp.loppnum';
.... both work correctly.
I simply want to set the value of $fishnet to define the where clause
Any greatly appreaciated
Garry Jones
Sweden
|