1

我正在开发一个新的票务系统,但出了点问题。当用户没有打开的工单时,它应该显示以下消息:

 <?}else{?>
<tr>
     <td style="background:#f7f7f7;">There are no tickets submitted yet.</td>
     </tr>
<?}?>

我可能做错了什么,我不知道在哪里。这是我拥有的代码:

<?php 
if($_GET['a'] == "del" && $_GET['id'] != ""){
mysql_query("DELETE FROM message WHERE id='{$_GET['id']}' LIMIT 1;");
}

$msg = mysql_query("SELECT * FROM `message` WHERE `receiver`='{$_SESSION['login']}' ORDER BY date DESC")or die (mysql_error());
?>
<table id="nested" width="97%" cellspacing=0 cellpadding=0 style="border-collapse:collapse;">
<tr><th width="50px">ID</th><th width="110px">Date</th><th width="165px">Title</th><th width="90px">Status</th><th align="right" width="60px">Actions</th></tr></div>
<tbody>
<?php 
while($mesg = mysql_fetch_array($msg)) {
?>
<tr class="">
<th><?php echo $mesg['id']; ?> </th>
<td><?php echo $mesg['date']; ?> </td>
<td><?php echo $mesg['title']; ?> </td>

<td><?php
if($mesg['readed']) { echo "Read";
}else{ echo "Unread";
} ?> </td>
<th><ul class="action-buttons">


<li><a href="#myTickets?id=<?=$mesg['id']?>" class="action-button" title="Read"><span class="read"></span></a></li>
                <li><a href="#myTickets?a=del&id=<?=$mesg['id']?>" class="action-button" title="Delete"><span class="delete"></span></a></li>
                <li><a href="#myTickets?a=close&id=<?=$mesg['id']?>" class="action-button" title="Close"><span class="close"></span></a></li></ul>

<? } ?>

 </th>

<?}else{?>
    <tr>
         <td style="background:#f7f7f7;">There are no tickets submitted yet.</td>
         </tr>
    <?}?>

</tr>

</tbody>
</table>
</table>

如果有人可以帮助我,我将不胜感激,谢谢!

4

2 回答 2

0

请检查您的牙套。它不平衡。

<?php 
     if( mysql_num_rows($msg) == 0 ) { ?>    //means the query returns empty set.
        <tr>
             <td style="background:#f7f7f7;"> //There are no tickets submitted yet.</td>
        </tr>
<?php } else {  // you have messages
    while($mesg = mysql_fetch_array($msg)) {
         // finish ur while loop
 ?>
于 2013-04-09T19:24:35.887 回答
0

没有与 .if匹配的语句elseif有票时添加for ,或者只是将评估为else没有时的。iftrue

例如:

<?if ( mysql_num_rows($msg) == 0 ) {?>
    <tr>
        <td style="background:#f7f7f7;">There are no tickets submitted yet.</td>
    </tr>
<?}?>
于 2013-04-09T19:24:47.153 回答