php - 如果在 mysql 中有一个数字,则显示文本

标签 php mysql forms

我有一个包含 4 列的数据库,iduservipplanexpire。 我想做的是:

我有我的 vipplan 表,并且:
如果数字 0 在数据库中:则显示“N/A”
如果数字 1 在数据库中:则显示“Sr.Pro”
如果数字 2 在数据库中:则显示“No seas”
如果数字 3 在数据库中:则显示“Level0”

但我不知道该怎么做,我贴出我的代码:

<?php
echo "<h2>Resultados:</h2><p>";

  if(isset($_POST['user']))
        {
        $find = $_POST['user'];
        if ($find == "")
        {
        echo "<p>Olvidaste poner tu usuario -.-!!!";
        exit;
        }
mysql_connect("localhost", "root", "2513") or             die(mysql_error());
mysql_select_db("invasionvip") or die(mysql_error());
            $find = strtoupper($find);
            $find = strip_tags($find);
            $find = trim ($find);
            $iname = mysql_query("SELECT * FROM users WHERE usuario LIKE '%$find%'")
             or die(mysql_error());
            while($result = mysql_fetch_array( $iname ))
            {
            echo "id:" .$result['id'];
            echo "<br>";
            echo "usuario:".$result['usuario'];
            echo "<br>";
            echo "Plan VIP:".$result['planvip'];
            echo "<br>";
            echo "Vencimiento :".$result['vencimiento'];
            echo "<br>";
            }
            $anymatches = mysql_num_rows($iname);
            if ($anymatches == 0)
            {
            echo "Sorry, but we can not find an entry to match your query...<br><br>";
            }
            echo "<b>Searched For:</b> " .$find;
            }
            ?>

我的表格很简单:

<form class="pure-form" method="post" action="user.php">
<center>Aqui podrás ver tus servicios activos, como V.I.P, vehiculos, skins, etc.</center><br/>
<span style="text-align:left;font-size:25px;">Usuario:&nbsp;</span>
<input type="text" name="user">
<button type="submit" class="pure-button">Search</button>
</form>

谢谢你,:)

最佳答案

我相信你追求的是 case select .您应该将其放在查询的选择行中。

关于php - 如果在 mysql 中有一个数字,则显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32644451/

相关文章:

javascript - 当选中某个单选按钮时,如何使复选框组处于事件或不活动状态?

php - 如何从 Laravel session 中删除数组

PHP + Javascript - 读/写 Cookie

javascript - PHP 无法将所选表中的数组填充到 json_encode 并在 javascript 上接收它

mysql - 根据一列值删除重复行

php - SQL 升级和规则表

mysql - 如何优化 MySQL 中的 IN 子查询?

jquery - 当翻转切换器进入 jquery mobile 中的开启状态时如何提交表单

jquery - 使用ajax将 "submit"处理程序递归附加到表单?

PHP 剩余时间百分比