php - 如何在php中获取链接的值id

标签 php html css

嗯,这是我第一次在这个网站上提问,所以请有人帮我解决这个问题。

我想通过单击表中的名称来显示我的客户信息,当我单击它时,我想在模式中查看信息。这是我的代码

<?php
include 'config.php';
$data = mysqli_query($con,"SELECT * FROM appliancesrep") or die(mysqli_error());
echo "<tbody>";
while($row = mysqli_fetch_array($data)){
  echo "<tr>";
  echo '<td>' .$row['descr']. '</td>';
  echo '<td>' .$row['model']. '</td>';
  echo '<td>' .$row['brand']. '</td>';
  echo '<td>' .$row['purchased']. '</td>';
  echo  limit($row['problem'],20);
$str = mysqli_query($con,"SELECT * from customer WHERE id =" . $row['id']);
while($row = mysqli_fetch_array($str)){
echo '<td><a data-toggle="modal" data-target="#exampleModal"href="'.$row['fname'].$row['mname'] . $row['lname']. '" value="' .$row['id']. '">' .$row['fname']."".$row['mname']." " .$row['lname'].  '</a></td>';
echo "<div class='modal fade' id='exampleModal' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel'>
<div class='modal-dialog' role='document'>
<div class='modal-content'>
<div class='modal-body'>
<form>
<div class='form-group'>
<label for='recipient-name' class='control-label'>Name:</label>
<label for='recipient-name' class='control-label' value='" .$row['id']. "'>" .$row['fname']." ".$row['mname']." " .$row['lname']. "</label></div>
<div class='form-group'>
<label for='recipient-name' class='control-label'>Gender:</label>
<label for='recipient-name' class='control-label'>".$row['gender']."</label>
</div>
</form>
<div class='modal-footer'>
<button type='button' class='btn btn-danger'>Delete</button>
<button type='button' class='btn btn-primary' data-dismiss='modal'>Close</button>
        </div>
      </div>
    </div>
  </div>
  }
}
echo "</tr>";
echo "<tbody>";
?>

当我第一次在第一个名为 Rick 的客户中尝试时,输出是正常的,但是当我单击另一个名为 John 的客户时,Rick 的信息将会出现,而不是 John,我注意到当我总是单击模态时我的网页容器的宽度越来越小。

好吧,我终于弄清楚了信息的事情,这是我的代码..

$str = mysqli_query($con,"SELECT * from customer WHERE id =" . $row['id']);
while($row = mysqli_fetch_array($str)){
echo '<td><a data-toggle="modal" data-target="#'.$row['id'].'" value="'.$row['id']. '">' .$row['fname']."".$row['mname']." " .$row['lname'].  '</a></td>';
echo "<div class='modal fade' id='".$row['id']."' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel'>
<div class='modal-dialog' role='document'>
<div class='modal-content'>
<div class='modal-body'>
<form>
<div class='form-group'>
<label for='recipient-name' class='control-label'>Name:</label>
<label for='recipient-name' class='control-label' value='" .$row['id']. "'>" .$row['fname']." ".$row['mname']." " .$row['lname']. "</label></div>
<div class='form-group'>
<label for='recipient-name' class='control-label'>Gender:</label>
<label for='recipient-name' class='control-label'>".$row['gender']."</label>
</div>
</form>
<div class='modal-footer'>
<button type='button' class='btn btn-danger'>Delete</button>
<button type='button' class='btn btn-primary' data-dismiss='modal'>Close</button>
        </div>
      </div>
    </div>
  </div>
  }
}
echo "</tr>";
echo "<tbody>";
?>

我现在只更改链接的数据目标和模态的 id,我唯一的问题是每次我单击我的模态时,我的容器的宽度都变小了,是因为标签吗???

最佳答案

 <div class='modal-footer'>
<button type='button' class='btn btn-danger'>Delete</button>
<button type='button' class='btn btn-primary' data-dismiss='modal'>Close</button>
    </div>
  </div>
</div>
</div>";
}
}
echo "</tr>";
echo "<tbody>";

在最后一个div标签后面加上代码";,并纠正语法错误。

关于php - 如何在php中获取链接的值id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31646075/

相关文章:

php - Steam api 用户数据 : Only works for one steam id, 否则不起作用

php - 我在哪里可以下载 Facebook 的 PHP 源代码转换器 HipHop

javascript - 是否可以在不使用客户端 Javascript 的情况下创建服务器端 Javascript 网站?

javascript - 不确定我的简单代码有什么问题

css - 无法在页脚内的同一行上获取 div

html - Bootstrap 下拉菜单在轮播幻灯片中不起作用

javascript - PHP 获取唯一标识

php - .htaccess 重写问题

html - 视频在 Safari 和 Chrome 中比在 Firefox 中渲染得稍微亮一些

html - WkHTMLtoPDF 不加载本地 CSS 和图像