PHP表中的换行符
我的项目有点显示问题 事实上,我希望在表中显示一些信息(sql请求的列类型PHP表中的换行符,php,mysql,sql,twitter-bootstrap,Php,Mysql,Sql,Twitter Bootstrap,我的项目有点显示问题 事实上,我希望在表中显示一些信息(sql请求的列类型SHOW Columnsbtw),但它不能正确显示 代码是: 试试看 { 回声'; 回声' 列名 类型 更新 删除 '; 回声'; $sql=$bdd->query(“显示来自“.$table”的列); $column_name=$bdd->query('select column_name from information_schema.columns,其中table_name=“”.$table.”和table_sch
SHOW Columns
btw),但它不能正确显示
代码是:
试试看
{
回声';
回声'
列名
类型
更新
删除
';
回声';
$sql=$bdd->query(“显示来自“.$table”的列);
$column_name=$bdd->query('select column_name from information_schema.columns,其中table_name=“”.$table.”和table_schema=“.$db_name.”);
$i=0;
而($donnees=$column\u name->fetch())
{
$column=$donnees[$i];
回声“.$donnees[$i]”;
而($row=$sql->fetch())
{
回显'.$row[“Type”].';
}
?>
试试这个
try
{
echo '<table class="table table-bordered table-striped mb30 mt30">';
echo'<thead>
<th class="text-center">Name of column</th>
<th class="text-center">Type</th>
<th class="text-center">Update</th>
<th class="text-center">Delete</th>
</thead>';
echo'<tbody>';
$sql = $bdd->query("SHOW COLUMNS FROM ".$table);
$column_name = $bdd->query('select column_name from information_schema.columns where table_name = "'.$table.'" and table_schema = "'.$db_name.'" ');
$i = 0;
while($donnees = $column_name->fetch())
{
$column = $donnees[$i];
while ($row = $sql->fetch())
{
echo '<tr><td class="col-db text-center">'.$donnees[$i].'</td><td class="col-db text-center">'.$row["Type"].'</td><td><p class="text-center"><a href="form_update_table.php?database='.'$db_name.'&table='.$table.'&column='.$column.'" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-pencil"></span></a></p></td>
<td><p class="text-center"><a href="drop_column.php?database='.$db_name.'&table='.$table.'&column='.$column.'" onclick="return confirm_delete()" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span></a></p></td></tr>';
}
?>
<?php
}
$i = $i + 1;
试试看
{
回声';
回声'
列名
类型
更新
删除
';
回声';
$sql=$bdd->query(“显示来自“.$table”的列);
$column_name=$bdd->query('select column_name from information_schema.columns,其中table_name=“”.$table.”和table_schema=“.$db_name.”);
$i=0;
而($donnees=$column\u name->fetch())
{
$column=$donnees[$i];
而($row=$sql->fetch())
{
回显'.$donnees[$i].'.$row[“Type”].
;
}
?>
这有帮助吗
try
{
echo '<table class="table table-bordered table-striped mb30 mt30">';
echo'<thead>
<th class="text-center">Name of column</th>
<th class="text-center">Type</th>
<th class="text-center">Update</th>
<th class="text-center">Delete</th>
</thead>';
echo'<tbody>';
$column_name = $bdd->query('select column_name, data_type from information_schema.columns where table_name = "'.$table.'" and table_schema = "'.$db_name.'" ');
while($donnees = $column_name->fetch_assoc())
{
$column = $donnees['column_name'];
echo '<tr><td class="col-db text-center">'.$donnees['column_name'].'</td>';
echo '<td class="col-db text-center">'.$donnees['data_type'].'</td>';
?>
<td><p class="text-center"><a href="form_update_table.php?database=<?php echo $db_name;?>&table=<?php echo $table;?>&column=<?php echo $column;?>" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-pencil"></span></a></p></td>
<td><p class="text-center"><a href="drop_column.php?database=<?php echo $db_name;?>&table=<?php echo $table;?>&column=<?php echo $column;?>" onclick="return confirm_delete()" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span></a></p></td></tr>
<?php
}
}
试试看
{
回声';
回声'
列名
类型
更新
删除
';
回声';
$column_name=$bdd->query('select column_name,data_type from information_schema.columns,其中table_name=“.”.$table.”和table_schema=“.”.$db_name.”);
而($donnees=$column\u name->fetch\u assoc())
{
$column=$donnees['column_name'];
回显'.$donnees['column_name'].';
回显'.$donnees['data_type'].';
?>
删除第二个while。secon while正在打印一行中的所有类型。这就是出现问题的原因。如果您在第一个循环中的每个圆中只获得一个数据,它将正常工作
while($donnees = $column_name->fetch()) {
$column = $donnees[$i];
echo '<tr><td class="col-db text-center">'.$donnees[$i].'</td>';
$row = $sql->fetch();
echo '<td class="col-db text-center">'.$row["Type"].'</td>';
?>
<td><p class="text-center"><a href="form_update_table.php?database=<?php echo $db_name;?>&table=<?php echo $table;?>&column=<?php echo $column;?>" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-pencil"></span></a></p></td>
<td><p class="text-center"><a href="drop_column.php?database=<?php echo $db_name;?>&table=<?php echo $table;?>&column=<?php echo $column;?>" onclick="return confirm_delete()" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span></a></p></td></tr>
<?php
}
while($donnees=$column\u name->fetch()){
$column=$donnees[$i];
回声“.$donnees[$i]”;
$row=$sql->fetch();
回显'.$row[“Type”].';
?>
你是什么意思?Ps:a
什么也不改变*(我的坏lol)@NassimElHormi问题是否解决了?@PraveenKumar信息没有换行符,我不明白为什么$sql=$bdd->query(“显示来自“$table”的列);
似乎没有必要使用mysqli?这行中有一个问题:echo'.$donnees[$I].$row[“键入”]。使用&table我无法获取它,这就是为什么我无法启动codeCorrected,请立即尝试。乐意帮助..:D