【发布时间】:2019-01-06 23:37:39
【问题描述】:
所以,我有这段代码可以返回一个简单的表,其中包含正确的 db 值:
<?php
echo "<table border='1'>
<tr>
<th>Código</th>
<th>Nome</th>
<th>Indicou</th>
</tr>";
while($coluna_bd_tabela = mysqli_fetch_array($sql_indicador_resul)){
echo "<tr>";
echo "<td>" . $coluna_bd_tabela['usu_codigo'] . "</td>";
echo "<td>" . $coluna_bd_tabela['usu_nome'] . "</td>";
echo "<td>" . $coluna_bd_tabela['usu_indicador_codigo'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
这是一个程式化的表格,没有查询工作:
<table class="table table-striped projects">
<thead>
<tr>
<th style="width: 1%">#</th>
<th style="width: 20%">Nome</th>
<th>Membros Recentes</th>
<th>Project Progress</th>
<th>Status</th>
<th style="width: 20%">#Edit</th>
</tr>
</thead>
<tbody>
<tr>
<td>echo $coluna_bd_tabela['usu_codigo']</td>
<td>
<a> echo $coluna_bd_tabela['usu_nome']</a>
<br />
<small>echo $coluna_bd_tabela['usu_indicou']</small>
</td>
<td>
<ul class="list-inline">
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
</ul>
</td>
<td class="project_progress">
<div class="progress progress_sm">
<div class="progress-bar bg-green" role="progressbar" data-transitiongoal="57"></div>
</div>
<small>57% Complete</small>
</td>
<td>
<button type="button" class="btn btn-success btn-xs">Success</button>
</td>
<td>
<a href="#" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i> View </a>
<a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Edit </a>
<a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> Delete </a>
</td>
</tr>
</tbody>
我想显示带有查询值的程式化表格,但这正在摧毁我。数据库连接很好,这些是包含连接上的查询,它们也可以正常工作,如简单表所示:
$sql_indicador = "SELECT * FROM esc_usuarios WHERE usu_indicador_codigo = '" . $_SESSION['codigo'] . "'";
$sql_indicador_resul = mysqli_query($conexao, $sql_indicador);
【问题讨论】:
-
-
^ 那也是。我实际上很困惑您所说的实际上是按您的喜好工作,而哪个不起作用。您可能只需要那些打开/关闭 php 标记...然后用
while包裹在您的tbody中。 -
如果我错了,请忽略我,但不能使用某些浏览器插件更改 $_SESSION 变量吗?在这种情况下,我建议您转义您在 MySQL 查询中使用的会话变量。
-
是的,我知道,但它只会显示许多用户中的一个,我想生成数据库中存在的尽可能多的用户
标签: php mysqli while-loop html-table