Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Mysql将空行替换为';在';条件_Php_Mysql - Fatal编程技术网

Php 使用Mysql将空行替换为';在';条件

Php 使用Mysql将空行替换为';在';条件,php,mysql,Php,Mysql,这是我的密码 $Qemaster="select * from emaster where `branch`='$bid' and `department`='$did' and `status`!='L'"; $Remaster=mysql_query($Qemaster); while($Rowemaster=mysql_fetch_array($Remaster)){ $empcode=$Rowemaster[id]; $name=$Rowemaster[name];

这是我的密码

$Qemaster="select * from emaster where `branch`='$bid' and `department`='$did' and `status`!='L'";
$Remaster=mysql_query($Qemaster);
while($Rowemaster=mysql_fetch_array($Remaster)){
    $empcode=$Rowemaster[id];
    $name=$Rowemaster[name];
    $Tleave=0;

echo "<tr>";
echo "<td rowspan='2'>".$name."</td>";
echo "<td>Leave</td>";

$Qlp="select `leave` from lpsummary where ((`month` IN(04,05,06,07,08,09,10,11,12) and `year`='$year') or (`month` IN(01,02,03) and `year`='$Nyear')) and `empcode`='$empcode'";
$Rlp=mysql_query($Qlp);
while($Rowlp=mysql_fetch_array($Rlp)){  

$leave=$Rowlp['leave'];
$Tleave=$Tleave+$leave;

echo "<td>".$leave."</td>";
}
echo "<td><font color='red'>".$Tleave."</font></td>";
echo "<tr><td>Percentage</td>";
}

此处以Rajan的名字命名,jun-12中没有数据,但jul-12的值为2…即)表格lpsummary中的空行。。。。。。如果有空的,我想用“-”替换它。。。我怎样才能用我的代码做到这一点

在while循环中,需要设置一个条件来检查是否返回了null from

while($Rowlp=mysql_fetch_array($Rlp)){  
    if (is_null($Rowlp['leave'])) {
        $leave = '-';
    } else {
        $leave=$Rowlp['leave'];
        $Tleave=$Tleave+$leave;
    }

    echo "<td>".$leave."</td>";
}
while($Rowlp=mysql\u fetch\u数组($Rlp)){
如果(为空($Rowlp['leave'])){
$leave='-';
}否则{
$leave=$Rowlp['leave'];
$Tleave=$Tleave+$LEVE;
}
回显“$离开”;
}
while($Rowlp=mysql_fetch_array($Rlp)){  
    if (is_null($Rowlp['leave'])) {
        $leave = '-';
    } else {
        $leave=$Rowlp['leave'];
        $Tleave=$Tleave+$leave;
    }

    echo "<td>".$leave."</td>";
}