票证系统 - 当用户没有票证时显示消息

时间:2013-04-09 19:17:32

标签: php ticket-system

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

 <?}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>

如果有人能帮助我,我会非常感激,谢谢!

2 个答案:

答案 0 :(得分: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
 ?>

答案 1 :(得分:0)

没有if语句与else匹配。在有故障单时添加if,或者只在时将else更改为评估为if的{​​{1}}票。

例如:

true