如何使用 php 和 sql 连接 html 风格化表 [英] How to concatenate html stylized table with php and sql
问题描述
所以,我有这个代码返回一个带有正确数据库值的简单表:
<tr><th>Código</th><th>Nome</th><th>Indicou</th></tr>";而($coluna_bd_tabela = mysqli_fetch_array($sql_indicador_resul)){echo "";回声<td>".$coluna_bd_tabela['usu_codigo'] ."</td>";回声<td>".$coluna_bd_tabela['usu_nome'] ."</td>";回声<td>".$coluna_bd_tabela['usu_indicador_codigo'] ."</td>";回声</tr>";}echo "</table>";?>这是没有查询工作的风格化表格:
<头><tr><th style="width: 1%">#</th><th style="width: 20%">Nome</th><th>最近的成员</th><th>项目进展</th><th>状态</th><th style="width: 20%">#Edit</th></tr></thead><tr><td>echo $coluna_bd_tabela['usu_codigo']</td><td><a>echo $coluna_bd_tabela['usu_nome']<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><img src="images/user.png" class="avatar" alt="Avatar"><li><img src="images/user.png" class="avatar" alt="Avatar"><li><img src="images/user.png" class="avatar" alt="Avatar"></td><td class="project_progress"><div class="progress progress_sm"><div class="progress-bar bg-green" role="progressbar" data-transitiongoal="57"></div><small>57% 完成</small></td><td><button type="button" class="btn btn-success btn-xs">成功</button></td><td><a href="#" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i>查看<a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i>编辑<a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i>删除</td></tr></tbody>
我想显示带有查询值的风格化表格,但这毁了我.数据库连接很好,这些是对包含连接的查询,它们也工作正常,如简单表所示:
$sql_indicador = "SELECT * FROM esc_usuarios WHERE usu_indicador_codigo = '" .$_SESSION['codigo'] ."'";$sql_indicador_resul = mysqli_query($conexao, $sql_indicador);
解决方案提供完整的解决方案:
<头><tr><th style="width: 1%">#</th><th style="width: 20%">Nome</th><th>最近的成员</th><th>项目进展</th><th>状态</th><th style="width: 20%">#Edit</th></tr></thead><?php while($coluna_bd_tabela = mysqli_fetch_array($sql_indicador_resul)){ ?><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'];?></小></td><td><ul class="list-inline"><li><img src="images/user.png" class="avatar" alt="Avatar"><li><img src="images/user.png" class="avatar" alt="Avatar"><li><img src="images/user.png" class="avatar" alt="Avatar"><li><img src="images/user.png" class="avatar" alt="Avatar"></td><td class="project_progress"><div class="progress progress_sm"><div class="progress-bar bg-green" role="progressbar" data-transitiongoal="57"></div><small>57% 完成</small></td><td><button type="button" class="btn btn-success btn-xs">成功</button></td><td><a href="#" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i>查看<a href="#" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i>编辑<a href="#" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i>删除</td></tr></tbody><?php } ?>
您忘记在 echo 语句周围使用 <?php
和 ?>
开始和结束标记.此外,您错过了每个语句末尾的 ;
.我还将表格的开头和结尾移出了 PHP 的 echo
,因为我相信这样看起来更清晰.
So, i have this code that returns me a simple table with the correct db values:
<?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>";
?>
And this one is the stylized table without the querys working:
<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>
I want to show the stylized table with the values of the querys, but this is destroying me. The database connection is fine, these are the querys on a include connection, they are working fine too, as have been shown on the simple table:
$sql_indicador = "SELECT * FROM esc_usuarios WHERE usu_indicador_codigo = '" . $_SESSION['codigo'] . "'";
$sql_indicador_resul = mysqli_query($conexao, $sql_indicador);
解决方案 To provide a full solution:
<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>
You forgot to use the <?php
and ?>
opening and closing tags around the echo statements. Furthermore, you missed the ;
at the end of each statement. I've also moved the beginning and the end of the table out of PHP's echo
since I believe it looks much clearer this way.
这篇关于如何使用 php 和 sql 连接 html 风格化表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
登录
关闭
扫码关注1秒登录
发送“验证码”获取
|
15天全站免登陆