所以,我有这段代码可以为我返回一个带有正确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);
答案 0 :(得分:1)
要提供完整的解决方案:
<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>
<?php while($coluna_bd_tabela = mysqli_fetch_array($sql_indicador_resul)){ ?>
<tbody>
<tr>
<td><?php echo $coluna_bd_tabela['usu_codigo']; ?></td>
<td>
<a><?php echo $coluna_bd_tabela['usu_nome']; ?></a>
<br />
<small><?php 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>
<?php } ?>
</table>
您忘记在echo语句周围使用<?php
和?>
开头和结尾标签。此外,您在每个语句末尾都错过了;
。我也将表的开头和结尾从PHP的echo
中移出了,因为我认为这样看起来更清楚了。