dongxun1142 2017-04-18 05:00
浏览 25
已采纳

php / sql:不正确回显show数据

i have a problem with my php and sql code. I trying to make code that when i enter some data that related with the database, the output should show 'zero' if the row user_designid equal to 0 and if vice versa it will show 'one'. but the problem is both of output only show the first anwser ('zero').

Php file (co.php is my config)

 <?php
 require "co.php";
 $link = mysqli_connect($h,$u,$p,$db);

 if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
 }
echo "Connected successfully";

$q = "select * from tab_ss_user where User_name ='".$_POST['name']."'";
$result = mysqli_query($link,$q);


if($result){
echo "<table border='1' >
<tr>
<td align=center> <b>user Id No</b></td>
<td align=center><b>Name</b></td>
<td align=center><b>Password</b></td>
<td align=center><b>responsibility</b></td></td>";

while($data = mysqli_fetch_row($result))
{   
echo "<tr>";
echo "<td align=center><option>$data[0]</option></td>";
echo "<td align=center>$data[1]</td>";
echo "<td align=center>$data[2]</td>";

    //this is the problem
if($data['User_DesignID'] == 0 ){
      echo "<td align=center> zero </td>";
 }
else{
      echo "<td align=center> one </td>";
 }


   echo "</tr>";
 }
   echo "</table>";
 }

  else{
   echo ' Failed';
 }
 ?>

that all thank you.

  • 写回答

3条回答 默认 最新

  • doouzlrvb01417498 2017-04-18 06:35
    关注

    You are not referencing the field correctly See enter link description here

    When using mysqli_fetch_row, the result is an associative array so $data['User_DesignID'] will not be referenced correctly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?