Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用php将SQL数据迭代到html表';td';而不是变得一团糟_Php_Mysql_Wordpress_Laravel_Drupal - Fatal编程技术网

无法使用php将SQL数据迭代到html表';td';而不是变得一团糟

无法使用php将SQL数据迭代到html表';td';而不是变得一团糟,php,mysql,wordpress,laravel,drupal,Php,Mysql,Wordpress,Laravel,Drupal,我正在尝试使用PHP从Mysql数据库创建一个包含数据的表 我试图将数据迭代到表的头部分和表的主体部分 因此,如果我将数据添加到我的“资产剥离”表或MYSQL数据库中的“项目”,它将自动更新。 有人知道我如何迭代数据到第二列而不造成混乱吗。 我的表中的第一个迭代列似乎没有问题,当我尝试迭代到第二个名为beers的列时,表开始变得一团糟 <?php include 'tpl/header.php' ?> <?php include 'dbconnect.php'?> &

我正在尝试使用PHP从Mysql数据库创建一个包含数据的表 我试图将数据迭代到表的头部分和表的主体部分 因此,如果我将数据添加到我的“资产剥离”表或MYSQL数据库中的“项目”,它将自动更新。 有人知道我如何迭代数据到第二列而不造成混乱吗。 我的表中的第一个迭代列似乎没有问题,当我尝试迭代到第二个名为beers的列时,表开始变得一团糟


<?php include 'tpl/header.php' ?>
<?php include 'dbconnect.php'?>

<a style="margin-left:300px;margin-top:-200px" href="#" class="btn btn-primary">
                <i class="fas fa-plus-circle"></i>
                Add User 
    
            </a>
<table class="table table-bordered" style="margin-left:300px;margin-top:40px; border: 2px solid grey; width:50%">

<thead>
<tr>
<?php foreach($db->query("SELECT name FROM diversities WHERE id =1") as $row):?>
<th><?=$row['name']?></th>
<?php endforeach;?>
<?php foreach($db->query("SELECT name FROM diversities WHERE id =2") as $row):?>
<th><?=$row['name']?></th>
<?php endforeach;?>
<?php foreach($db->query("SELECT name FROM diversities WHERE id =3") as $row):?>
<th><?=$row['name']?></th>
<?php endforeach;?>

</tr>



</thead>

<tbody>
<tr>
<?php foreach($db->query("SELECT name FROM items WHERE CATALOG_NUM =1 LIMIT 3") as $row):?>
<td><?=$row['name']?></td>
<td></td>
<td></td>
</tr>
<?php endforeach;?>


</tbody>

</table>





<?php include 'tpl/footer.php' ?>