引导分页和搜索的问题 [英] Problem with bootstrap pagination and search

查看:94
本文介绍了引导分页和搜索的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!



我正在使用Php,Bootstrap和MySQL创建一个小项目。当我通过点击它的菜单显示数据Bootstrap分页和搜索工作正常,但当我尝试添加新的数据分页和搜索不起作用。调用bootstrap表插件的脚本包含在我的fetch脚本中,但我无法弄清楚为什么不能正常工作。有关如何解决这个问题的任何想法?提前谢谢。



我的尝试:



Hi!

I'm creating a small project using Php, Bootstrap and MySQL. When I display the data by clicking it's menu Bootstrap pagination and search is working fine, but when I try to add new data pagination and search is not working. My script calling the bootstrap table plugins is included to my fetch script but I can't figure out why is not working. Any idea on how to solve this problem? Thank you in advance.

What I have tried:

//PHP FETCH DATA

<?php 

include_once('../connection/pdo_db_connection.php');

$database = new Connection();
$db = $database->open();

	try {
		$data = $db->query("SELECT sid, asset_tag, particulars, status, user FROM sys_stocks WHERE status='AVAILABLE' ORDER BY asset_tag ASC")->fetchAll();
	foreach ($data as $row) {
	?>

    <tr>
	    <td><?php echo $row['asset_tag']; ?></td>
	    <td><?php echo $row['particulars']; ?></td>
		<td><?php echo $row['status']; ?></td>
		<td><?php echo $row['user']; ?></td>
	    <td>
			<button class="EditStocks" data-sid="<?php echo $row['sid']; ?>"></button>
	    	<button class="deletestocks" data-sid="<?php echo $row['sid']; ?>"></button>
		</td>				
	</tr>
	<?php
	}
}
	catch(PDOException $e) {
	echo "There's a problem with the connection: " . $e->getMessage();
	}
	    //close connection
		$database->close();
?>

//AJAX ADD DATA

	$('#AddStocks').click(function(){
		$('#AddStocksModal').modal('show');
	});
	$('#addFormstocks').submit(function(e){
		e.preventDefault();
		var addform = $(this).serialize();
		//console.log(addform);
		$.ajax({
			method: 'POST',
			url: 'functions/add_stocks_submit.php',
			data: addform,
			dataType: 'json',
			success: function(response){
				$('#AddStocksModal').modal('hide');
				$(this).find('form').trigger('reset');
				if(response.error){
					$('#alert').show();
					$('#alert_message').html(response.message);
				}
				else{
					$('#alert').show();
					$('#alert_message').html(response.message);
					fetch();
				}
			}
		});
	});
	//

//FETCH DATA TO DISPLAY

function fetch(){
	$.ajax({
		method: 'POST',
		url: 'functions/stocks_fetch.php',
		success: function(response){
			$('#tblbody').html(response);

			//SCRIPT CALLING BOOTSTRAP PLUGINS
               $(document).ready(function() {
                $('#dataTable').DataTable();
               });    
            //
		   }
	     });
       }

//TABLE

<pre> <div class="card shadow mb-4">
   <div class="card-header py-3">
     <center><h6 class="m-0 font-weight-bold text-primary">LIST OF STOCKS</h6> 
     </center>
   </div>
<div class="card-body">
  <div class="table-responsive">
    <table class="table table-bordered" id="dataTable" width="100%"    
      cellspacing="0">
                  <thead>
                    <tr>
                      <th>ASSET TAGS</th>
                      <th>PARTICULARS</th>
                      <th>STATUS</th>
                      <th>PREVIOUS USER</th>
                      <th>OPTION</th>
                    </tr>
                  </thead>
                  <tfoot>
                    <tr>
                      <th>ASSET TAGS</th>
                      <th>PARTICULARS</th>
                      <th>STATUS</th>
                      <th>PREVIOUS USER</th>
                      <th>OPTION</th>
                    </tr>
                  </tfoot>
                  <tbody id="tblbody"></tbody>
                </table>
              </div>
            </div>
          </div>

推荐答案

database = new Connection();
database = new Connection();


db =


database-> open();

尝试{
database->open(); try {


这篇关于引导分页和搜索的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆