Php 表中每个$行的If函数
我有一个表,它显示了来自调用流的数据。 我需要以这样一种方式对每行来自此表的数据进行操作,即从我的数据库中查找的表的所有值(现在是代码)都将转换为文本值。让我向你展示并解释: 我的桌子:Php 表中每个$行的If函数,php,mysql,Php,Mysql,我有一个表,它显示了来自调用流的数据。 我需要以这样一种方式对每行来自此表的数据进行操作,即从我的数据库中查找的表的所有值(现在是代码)都将转换为文本值。让我向你展示并解释: 我的桌子: <?php include_once "Connect2Martijn1.php"; ?> <link rel="stylesheet" href="CSSMartijn1.css"> </link> <head> <meta ch
<?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);
?>
呼叫流
呼叫流
呼叫流
表,td,th{
边框:1px纯黑;
}
翻译数据的示例(我希望如何翻译):
<?php
if ($row['statusAnswered'] ="NULL")
{
echo "Not Answered!";
}
else
{
echo "Answered!";
}
?>
我想要实现的是,例如,如果数据库中此行的值为空或不为空,那么$row['statusAnswered']中该表中的值将以文本形式显示为“已回答或未回答”
我该怎么做
现在我只能做到在桌子下面有一个回声回答:S
不知道如何按$row放置它。while($row=mysqli\u fetch\u array($result))
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>";
{
回声“;
回显“$row['calleridnum']”;
回显“$row['calleridname']”;
如果($row['StatusResponsed']==“NULL”| |$row['StatusResponsed']==“NULL”| |$row['StatusResponsed']==“NULL”| |$row['StatusResponsed']=”)
{
回声“没有回答!”;
}
其他的
{
回声“回答!”;
}
回显“$row['statusCalling']”;
回声“;
}
回声“;
while($row=mysqli\u fetch\u数组($result))
{
如果(!isset($row['statusAnswered']))
{
$answered=“未回答!”;
}
其他的
{
$answered=“answered!”;
}
回声“;
回显“$row['calleridnum']”;
回显“$row['calleridname']”;
回声“$”回答;
回显“$row['statusCalling']”;
回声“;
}
您可以使用
$checkstatus = if($row['statusAnswered'] = NULL) { echo "Not Answered!"; } else {echo "Answered!";};
然后通过替换来调用它
echo "<td>" . $row['statusAnswered'] . "</td>";
echo”“$行['statusAnswered']。"";
有
echo“{$checkstatus}”
echo”
努默
纳姆
地位
时间
";
while($row=mysqli\u fetch\u数组($result))
{
回声“;
回显“$row['calleridnum']”;
回显“$row['calleridname']”;
echo”“($row['statusAnswered']='NULL'?'Not response!':'responsed!')。”;
回显“$row['statusCalling']”;
回声“;
}
回声“;
亲爱的Deepanshu,感谢您的快速回复!在编辑脚本中的这些更改后,我注意到现在StatusResponsed列中的所有行都回显“已应答”。但在数据库中,并非此列中的所有行都具有NULL值。。这意味着我认为这个脚本只针对列中的一行,并更改整个列(该列中的所有行)的值,这是不对的。。你知道如何解决这个问题吗?这是先进的@肯特:不是这样的,你能告诉我在你的回答栏中有哪些值吗db@Kentje是“NULL”还是“NULL”,因为您需要比较if conditionPerfect!中的值:)非常感谢你,亲爱的!它的作品完美!你是最好的!希望我能投票支持你,但是没有足够的代表!再次感谢你!如果你在if条件中使用“=”,那么在if条件中应该是“=”亲爱的利亚姆·艾伦,谢谢你的快速回复!在编辑脚本中的这些更改后,我注意到现在StatusResponsed列中的所有行都回显“Not Responsed”。但在数据库中,并非此列中的所有行都具有NULL值。。这意味着我认为这个脚本只针对列中的一行,并更改整个列(该列中的所有行)的值,这是不对的。。你知道如何解决这个问题吗?这是先进的!美好的它的工作:)Thnx为解决这个问题的另一种方式!你是老板哟!:)干杯亲爱的Saket Bisht,感谢您的快速回复!在编辑脚本中的这些更改后,我注意到现在StatusResponsed列中的所有行都回显“已应答”。但在数据库中,并非此列中的所有行都具有NULL值。。这意味着我认为这个脚本只针对列中的一行,并更改整个列(该列中的所有行)的值,这是不对的。。你知道如何解决这个问题吗?这是先进的!嗯,我不知道你的数据库上有什么,但是试着用===运算符代替==并且把'NULL'改为NULL。Thnx Saket,但我一直都能让它工作:)但是我会尝试它们,只是为了知道它是如何工作的!干杯,它起作用了!好人!:)另一种方法!你也是老板!:)非常感谢。干杯
echo "<td>" . $row['statusAnswered'] . "</td>";
echo "<td>{$checkstatus}</td>"
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>";