0

我有一个表格,显示来自呼叫流的数据。我需要按行操作该表中的数据,以便从我的数据库中查找的表的所有值(现在在代码中)都将转换为文本值。让我向你展示并解释:

我的表:

<?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);
?>

(我希望如何)翻译数据的示例:

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

我想要实现的是例如。如果数据库中该行的值为 NULL 或 Not...

我该怎么做呢?

现在我只能实现在桌子下有 1 个回声,说 Answered :S 不知道如何将它放在每 $row 中。

4

4 回答 4

2
 while($row = mysqli_fetch_array($result))
      {
if (!isset($row['statusAnswered']))
{
      $answered = "Not Answered!";
}
else
{
      $answered =  "Answered!";
}
      echo "<tr>";
      echo "<td>" . $row['calleridnum'] . "</td>";
      echo "<td>" . $row['calleridname'] . "</td>";
      echo "<td>" . $answered . "</td>";
      echo "<td>" . $row['statusCalling'] . "</td>";
      echo "</tr>";
      }
于 2013-09-02T08:53:45.777 回答
1
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>";
于 2013-09-02T08:53:10.023 回答
0
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']=='NULL'?'Not Answered!':'Answered!') . "</td>";
  echo "<td>" . $row['statusCalling'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
于 2013-09-02T08:59:38.493 回答
-1

你可以使用;

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

然后通过替换来调用它;

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

和;

echo "<td>{$checkstatus}</td>"
于 2013-09-02T08:54:49.327 回答