dscs63759 2013-09-02 08:49
浏览 63
已采纳

如果表中的每行$行的函数

I have a table that shows me data from a call flow. I need the Data from this table to be manipulated per row in such a way that all the values of my table, which are being looked up from my DB, (which are now in code) will be translated into a text value. Let me show U and explain:

My Table:

<?php
include_once "Connect2Martijn1.php"; 
?>

  <link rel="stylesheet" href="CSSMartijn1.css">
   </link>



<head>
   <meta charset="iso-8859-1">
   <meta name="description"content="VoizXL ">
   <meta name="keywords"content="VoizXL ">
   <meta name="author"content="Kenn Lo-A-Tjong">
   </meta>
   <title>Call Flow</title>


</head>



<fieldset>
<article class="rondehoeken"> 
<header>
    <div class="streep1"></div>
    <div class="streep2"></div>
    <div class="streep3"></div>
    <div class="streep4"></div>
    <div class="streep5"></div>
    <h1 id="artikel-titel" >Call Flow</h1>
</header>

<div id="artikel-container">

<table class="table 1">
<thead>
 <title>Call Flow</title>
    <meta charset = "UTF-8" />
    <style type = "text/css">
    table, td, th {
      border: 1px solid black;
    } 
    </style>
</thead>

<tbody>
 <?php
$con=mysqli_connect("localhost","root","","voizxl_wachtrij");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT * FROM Callflow");

echo "<table border='0'>
<tr>
<th>Nummer</th>
<th>Naam</th>
<th>Status</th>
<th>Time</th>
</tr>";



while($row = mysqli_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['calleridnum'] . "</td>";
  echo "<td>" . $row['calleridname'] . "</td>";
  echo "<td>" . $row['statusAnswered'] . "</td>";
  echo "<td>" . $row['statusCalling'] . "</td>";
  echo "</tr>";
  }
echo "</table>";


mysqli_close($con);
?>

Example of (how I want to be) Translating the Data:

<?php
 if ($row['statusAnswered'] ="NULL")
      {
      echo "Not Answered!";
      }
    else
      {
      echo "Answered!";
      }
  ?>  

What I want to Achieve is for eg. that the value in this table from $row['statusAnswered'] will be displayed in text as "Answered or Not Answered" if the Value of this row in the DB is NULL or Not...

How do I do this?

Right now I can only achieve to have 1 echo under the table saying Answered :S No Idea how to put it per $row.

  • 写回答

4条回答 默认 最新

  • dongou3158 2013-09-02 08:53
    关注
    while($row = mysqli_fetch_array($result))
      {
      echo "<tr>";
      echo "<td>" . $row['calleridnum'] . "</td>";
      echo "<td>" . $row['calleridname'] . "</td>";
       if ($row['statusAnswered'] =="NULL"||$row['statusAnswered'] =="Null" || $row['statusAnswered'] =="null" || $row['statusAnswered'] =="")
          {
          echo "<td>Not Answered!</td>";
          }
        else
          {
          echo "<td>Answered!</td>";
          }
    
      echo "<td>" . $row['statusCalling'] . "</td>";
      echo "</tr>";
      }
    echo "</table>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?