dongqian8265 2010-05-24 14:40
浏览 63
已采纳

回显值为3的项目

I need to echo all items in my column that have the value of three. If a field has the value of three I then need to echo the 'name' and 'description' on that row.

This is what I have so far

$result = mysql_query($query1) or die(mysql_error());    
while ($row = mysql_fetch_array($result))    
{  
  echo $row['status'];
}

I need to write 'if $row[`status´ == 3 echo 'description' 'name' else echo 'no current staus'

I hope I made some sense because I am seriously confused

  • 写回答

8条回答 默认 最新

  • dphs48626 2010-05-24 15:13
    关注

    You can actually select the result which only has 3 value in its status

    for that use this

    $query = "SELECT * FROM yourtable WHERE status='3'";
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array(result)) {
          echo "Name: ".$row['name']."<br>Description: ".$row['description'];
    }
    

    and if you want to parse you result to display only those of value this then use this

    $query = "SELECT * FROM yourtable";
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array(result)) {
          if($row['status']==3) {
               echo "Name: ".$row['name']."<br>Description: ".$row['description'];
          }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?

悬赏问题

  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码