【问题标题】:How to insert data to bootstrap table with some code?如何使用一些代码将数据插入引导表?
【发布时间】:2019-05-31 19:45:33
【问题描述】:

在将数据插入引导表时遇到问题。部分代码太复杂,无法正确插入表格!

我已经尝试通过多种方式将该数据插入到表中,但到目前为止没有任何效果!

这是我想要的原始引导表!

    echo '<div class="example-wrap">
            <p>Filmsground Users</p>
            <div class="example table-responsive">
              <table class="table">
                <thead>
                  <tr>                        
                    <th>ID</th>
                    <th>Username</th>
                    <th>Modules Access</th>
                    <th>Edit</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td>1</td>
                    <td>Teagan</td>
                    <td>
                      <span class="label label-danger">admin</span>
                    </td>
                    <td>
                    <button type="button" class="btn btn-sm btn-icon btn-flat btn-default" data-toggle="tooltip"
                    data-original-title="Edit">
                    <i class="icon wb-wrench" aria-hidden="true"></i>
                    </button>
                     </td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>';

以及需要插入引导表的代码!

$query = mysqli_query($conn, "SELECT * FROM users ORDER BY id ASC");
    while ($results = mysqli_fetch_assoc($query))
    {
        echo '<p><strong><a href="?inav=useredit&id='.$results['id'].'">'.$results['username'].'</a></strong>: ';
        if ($results['membertype'] == 'admin')
        {
            echo 'Admin users have access to everything.';
        }
        else
        {
        $user = $results['username'];
        $query_prev = mysqli_query($conn, "SELECT * FROM user_prevs WHERE username='".$user."'");
            while ($prevs = mysqli_fetch_assoc($query_prev))
            {
                $pattern = '/\[module\](.*?)\[\/module\]/is';
                $replace = '$1 ';
                $module_name = preg_replace($pattern, $replace, $prevs['prevs']);

                echo $module_name;
            }

        }

    }

【问题讨论】:

    标签: php mysqli html-table bootstrap-4


    【解决方案1】:

    PHP 可以与 html 齐头并进。您可以使用这种方式:

     <?php
     if (mysqli_num_rows($result2) > 0)
       {  
     while($row4 = mysqli_fetch_assoc($result2))
       {
      ?>
       <tbody id="myTable">
        <tr >
       <td align="center"><?php echo $row4['articleID'];?>
        </td>
        <td  align="center"><?php echo $row4['articleName'];?>
        </td >
         <td align="center"><?php echo  $sordCodeFO; ?>
         </td>
         <td align="center"><?php echo $row4['color'];?>
         </td>
        <td align="center"><?php echo $row4['style'];?>
        </td>
        <td align="center"><?php echo $row4['size'];?>
       </td>
        <td align="center"><?php echo $row4['quantity'];?>
        </td></tr></tbody>
      <?php
        }
       }
      ?>
    

    【讨论】:

    • 感谢您的建议,但希望按原样使用!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-25
    • 2014-08-29
    • 1970-01-01
    • 2021-06-09
    • 2014-03-14
    • 1970-01-01
    • 2018-08-30
    相关资源
    最近更新 更多