-3

我正在按字段获取雇主记录emp_id,如果在First.

另外,我将如何调整条件表达式以使用新查询?

这是我要修复的代码:

<?php
$emp = mysql_query("SELECT * FROM employees
WHERE s_id = '" .$s. "' ORDER BY emp_id ASC");
while($names = mysql_fetch_array($emp)) { 
if ($names['Show'] == 'TRUE'){
?>
        <table width="100%" class="round1" border="1" cellspacing="0" cellpadding="0">
            <tr>
                <td height="7.5%" class="name_phone"
                    <div>
                        <?php 
                        if (($names['First'] == $names['First']) && ($names['u_id'] != $names['u_id']))
                        {echo $names['First'];}
                        else
                        {echo $names['First']. ' ' .$names['Last'];} ?>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="phone">
                    <div>
                        <?php if ($names['ShowPhone'] == 'TRUE')
                        {echo $names['Phone'];}
                        else
                        {echo '&nbsp;';} ?>
                    </div>
                </td>
            </tr>
        </table>
<?php }} ?>
4

3 回答 3

1

您需要使用 double==进行相等比较。

<?php 
if (($names['First'] == $names['First']) && ($names['u_id'] != $names['u_id']))
{echo $names['First'];}
else
{echo $names['First']. ' ' .$names['Last'];}
?>

比较运算符

于 2013-01-27T21:09:34.480 回答
0

==对于您使用或===(或!=或在您的情况下)的php比较!==,您使用的是赋值运算符。

于 2013-01-27T21:10:04.557 回答
0

修复代码:

     <?php 
                        if (($names['First'] == $names['First']) && ($names['u_id'] == $names['u_id']))
                        {echo $names['First'];}
                        else
                        {echo $names['First']. ' ' .$names['Last'];}
 ?>
于 2013-01-27T21:10:31.000 回答