如果值1更改为General,如何更改

时间:2017-02-04 21:00:09

标签: php

正如你在图片中看到的那样,我希望价值应该在其他地方,我有6个值可以达到?,但更愿意转到另一个词使用

http://image.prntscr.com/image/8c26c451b10a481f9a8d0aaba16bf311.png

正如你在图片中看到的那样,我希望价值应该在其他地方,我有6个值可以达到?,但更愿意转到另一个词使用

http://image.prntscr.com/image/1d271a5f156842d0ac88c5f9c8e114aa.png

正如你在图片中看到的,我希望它像那样。检查是值2它将是其他东西。使用"支持"出现在图像上我让最后一张图片

<?php
    $con = mysql_connect("localhost","root","**");
    if($con)
    {
            $db = mysql_select_db("habix");
            if($db)
            {
                    $sql = "select * from user_tickets_table";
                    $result = mysql_query($sql);
                    if($result) 
                    {

                        echo "<table border='1' style='width:100%'>";
                        echo "<tr>";
                        echo "<th>ID</th>";
                        echo "<th>Tittel</th>";
                        echo "<th>Beskjed</th>";
                        echo "<th>Dato</th>";
                        echo "<th>Type</th>";
                        echo "<th>Svar</th>";
                        echo "<th>Mer Muligheter</th>";
                        echo "</tr>";
                            while($row = mysql_fetch_array($result))
                            {
                                echo "<tr id='".$row['id']."'>";
                                echo "<td>".$row['id']."</td>";
                                echo "<td><textarea style='border:0px'>".$row['title']."</textarea></td>";
                                echo "<td><textarea style='border:0px'>".$row['message']."</textarea></td>";
                                echo "<td>".$row['ticketdate']."</td>";
                                echo "<td>".$row['issue_no']."</td>";
                                echo "<td>".$row['response']."</td>";
                                //echo "<td><button class='btn btn-primary' value='".$row['id']."' onclick='reply(".$row['id'].")'>Reply</button><button class='btn btn-primary' onclick='remove(".$row['id'].")'>Delete</button></td>";
                                echo "<td>";
                                echo "<form action='' method='post'><input type='hidden' name='idd' value='".$row['id']."'/><input type='submit' value='Slett!' name='del' onclick='return mycheck();'/></form>";
                                echo "</td>";
                                echo "</tr>";
                            }

                        echo "</table>";
                    }
                    else echo "Something is not right, Either there are no messages or some another error";
            }
            else echo "Error establishing database connection";
    }
    else echo "Error establishing connection to server";
?>

1 个答案:

答案 0 :(得分:0)

更改行

echo "<td>".$row['issue_no']."</td>";

$types = [1 => 'General', 2 => 'Support'];
echo "<td>".(isset($types[$row['issue_no']]) ? $types[$row['issue_no']] : $row['issue_no'])."</td>";

稍后将$types声明移到代码的上方是个好主意,因此不会在每次循环迭代时重新创建它。