<?
$oby=' $s_t<>"" ';
if ($st<>'')
{
$oby.=' and $s_t>='."'".$st."'";
}
else
{
$oby=$oby;
}if ($st1<>'')
{
$oby.=' and $s_t<='."'".$st1."'";
}
else
{
$oby=$oby;
}
if ($zt<>'')
{
$oby.=' and $r_t>='."'".$zt."'";
}
else
{
$oby=$oby;
}
if ($zt1<>'')
{
$oby.=' and $r_t<='."'".$zt1."'";
}
else
{
$oby=$oby;

?><? if ( $oby )
{ ?><?}?>
我想IF条件用变量来赋值可以吗??要怎么实现?

解决方案 »

  1.   

    if (($st<>''&&$oby.=' and $s_t>='."'".$st."'")||oby=$oby)
    你是要这种东西吗?
      

  2.   

    我感觉我写的这个 执行出来只判断了 $oby 有没有值。。
    并没有判断那里面的条件
      

  3.   

    你需要的是不是下面这个?
    if( (($st <> '') ? $s_t >= $st : true) && (($st1 <> '') ? $s_t <= $st1 : true) 
    && (($zt <> '') ? $r_t >= $zt : true) && (($zt1 <> '') ? $r_t <= $zt1 : true))
      

  4.   

    $oby=' $s_t<>"" ';
    这个是用来干嘛的?
      

  5.   

    上面少了第一个条件:
    if( $s_t <> '' && (($st <> '') ? $s_t >= $st : true) && (($st1 <> '') ? $s_t <= $st1 : true)
    && (($zt <> '') ? $r_t >= $zt : true) && (($zt1 <> '') ? $r_t <= $zt1 : true))
      

  6.   

     $obj .= $str <> '' ? '234' : '456';
      

  7.   

    $oby.=' and $s_t>='."'".$st."'";
    $oby.=' and $s_t<='."'".$st1."'";
    $oby.=' and $s_t<='."'".$st1."'";
    等等
    应该写成:
    $oby.=' and $s_t<=$st1';
    或$oby.=' and '.$s_t.'<='.$st1;
      

  8.   

    这个<>是要表示不等于吧?
    PHP里似乎是:!=