如何在Javascript表的特定列中插入按钮?

时间:2017-04-01 07:34:44

标签: javascript php html

这是我的表,其中包含我数据库中的数据:



<script type="text/javascript">
    
     var $table = $('#table');
     $table.bootstrapTable({
          url: 'list-user.php',
          search: true,
          pagination: true,
          buttonsClass: 'primary',
          showFooter: true,
          minimumCountColumns: 2,
          columns: [{
              field: 'num',
              title: '#',
              sortable: true,
              },{
              field: 'username',
              title: 'Username',
              sortable: true,
              },{
              field: 'email',
              title: 'Email',
              sortable: true,
              },{
              field: 'country',
              title: 'Country',
              sortable: true,
              },{
              field: 'password',
              title: 'Password',
              sortable: true,
              },{
              field: 'level',
              title: 'Level',
              sortable: true,
              },{
              field: 'costumize',
              title: 'Costumize',
              sortable: false,
              }],
          });
</script>
&#13;
&#13;
&#13;

这是我的php文件:

&#13;
&#13;
<?php 
	require 'conection.php';
 		
 		$sqltran = mysqli_query($conn, "SELECT * FROM login ")or die(mysqli_error($conn));
		$arrVal = array();
 		
		$i=1;
 		while ($rowList = mysqli_fetch_array($sqltran)) {
 								 
		    $name = array(
				'num' => $i,
 	 		 	'username'=> $rowList['username'],
 	 		 	'email'=> $rowList['email'],
 	 		 	'country'=> $rowList['country'],
	 		 	'password'=> $rowList['password'],
	 		 	'level'=> $rowList['user_type']
	 		);		


			array_push($arrVal, $name);	
			$i++;			
	 	}
	 	echo  json_encode($arrVal);		
	 	mysqli_close($conn); 	
?>   
 
&#13;
&#13;
&#13;

更新

我的html #table:

&#13;
&#13;
<!-- show user list -->
<div class="container-full" style="margin: 0px;">
    <div class="col-md-12">
        <div class="page-header">
            <h1>
                USER LIST
            </h1>
        </div>


        <div class="panel panel-success">
            <div class="panel-heading "> 
                <span class=""> User List of Bagus Gamestore             
              <br>
             </div>
                         
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-12">
                        <table  id="table"
                                data-show-columns="true"
                                data-height="460">
                        </table>
                 <!--Add record button-->
            <div class="pull-right"><button  type="button" class="btn btn-xs btn-primary" id="command-add" data-row-id="0">
            <span class="glyphicon glyphicon-plus"></span> <a href="#popup" style="color: white;"> Record </button></div>  
              <!--end of add record button-->  
                    </div>
                </div>
            </div>              
        </div>
    </div>
</div>
&#13;
&#13;
&#13;

我想为自定义列中的每一行添加一个编辑/删除按钮,我该怎么做?

Here is a picture of my table

任何评论都将不胜感激:)谢谢

0 个答案:

没有答案