1

私は自分のコードにこれらを持っています

$from_m = 1;
$to_m = 6;

while( $from_m <= $to_m )
{
    if($from_m == 1)
        $m = "January";

    if($from_m == 2)
        $m = "February";

    if($from_m == 3)
        $m = "March";


    $add = "OR month = '$m' ";

    $from_m++;
}

結果として

$add = "OR month = 'March' ";

私が欲しかったのは…

 $add = "OR month = 'January' OR month = 'February' OR month = 'March' ";

どうすればそのようにできますか?

助けはありますか?

4

3 に答える 3

4

これを交換

$add = "OR month = '$m' ";

$add .= "OR month = '$m' ";
于 2012-09-03T05:10:47.357 に答える
0
$from_m = 1;
$to_m = 6;

while( $from_m <= $to_m )
{
    if($from_m == 1)
        $m = "January";

    if($from_m == 2)
        $m = "February";

    if($from_m == 3)
        $m = "March";


    $add .= "OR month = '$m' ";

    $from_m++;
}
于 2012-09-03T05:09:57.450 に答える
-1

使用する:

$add .= "OR month = '$m' ";

それ以外の

$add = "OR month = '$m' ";
于 2012-09-03T05:09:23.703 に答える