我有一个简单的表视图。我无法搜索Product列。
下面是我的datek_h2h.php代码: <table id="novaltable" class="table table-bordered table-striped "
data-toggle="table"
data-search="true"
data-search-text=""
data-filter-control="true"
data-show-export="true"
data-click-to-select="true"
data-toolbar="#toolbar">
<thead>
<th>Name</th>
<th>Product</th>
<th>Color</th>
<th>Owner</th>
<th>User</th>
<th>Action</th>
</thead>
<tbody>
<?php
$query_datek_h2h=mysqli_query($conn,"select * from testingdata INNER JOIN user ON testingdata.iduser=user.iduser INNER JOIN name ON testingdata.idname=name.idname WHERE testingdata.deleted='no' ");
while($row=mysqli_fetch_array($query_datek_h2h)){
?>
<tr>
<td><?php echo $row['cust_name']; ?></td>
<td><?php echo $row['product']; ?></td>
<td><?php echo $row['color']; ?></td>
<td><?php echo $row['owner']; ?></td>
<td><?php echo $row['inisial']; ?></td>
<td>
<a href="#edit_datek_h2h<?php echo $row['iddata']; ?>" data-toggle="modal" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-edit"></span></a>
<a href="#delete_datek_h2h<?php echo $row['iddata']; ?>" data-toggle="modal" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-trash"></span></a>
<?php include ('button_datek_h2h.php'); ?>
</td>
</tr>
<?php
}
?>
</table>
我认为错误是由于这一节,因为如果删除这一节,它可以在Product列中搜索。
<?php include ('button_datek_h2h.php'); ?>
我在产品部分使用button_datek_h2h.php文件中的下拉菜单。
下面是我的button_datek_h2h.php代码:<!-- Delete -->
<div class="modal fade" id="delete_datek_h2h<?php echo $row['iddata']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<center><h3 class="modal-title" id="myModalLabel">Are you sure want to delete ??</h3></center>
</div>
<div class="modal-body">
<div class="container-fluid">
<!-- Confirmation Delete Table -->
<table>
<tr>
<td style="width:120px">Name</td>
<td style="width:010px">:</td>
<th style="width:200px"><?php echo $row['cust_name']; ?></th>
</tr>
<tr>
<td style="width:120px">Product</td>
<td style="width:010px">:</td>
<th style="width:200px"><?php echo $row['product']; ?></th>
</tr>
<tr>
<td style="width:120px">Color</td>
<td style="width:010px">:</td>
<th style="width:200px"><?php echo $row['color']; ?></th>
</tr>
<tr>
<td style="width:120px">Owner</td>
<td style="width:010px">:</td>
<th style="width:200px"><?php echo $row['owner']; ?></th>
</tr>
<tr>
<td style="width:120px">User</td>
<td style="width:010px">:</td>
<th style="width:200px"><?php echo $row['inisial']; ?></th>
</tr>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
<a href="delete_datek_h2h.php?iddata=<?php echo $row['iddata']; ?>" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> Delete</a>
</div>
</div>
</div>
</div>
<!-- /.modal -->
<!-- Edit -->
<div class="modal fade" id="edit_datek_h2h<?php echo $row['iddata']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<center><h4 class="modal-title" id="myModalLabel">Ubah</h4></center>
</div>
<div class="modal-body">
<div class="container-fluid">
<form method="POST" action="edit_datek_h2h.php?iddata=<?php echo $row['iddata']; ?>">
<div style="height:10px;"></div>
<div class="row">
<div class="col-lg-3">
<label style="position:relative; top:7px;">Name:</label>
</div>
<div class="col-lg-8">
<input type="text" name="name" class="form-control" value="<?php echo $row['cust_name']; ?>">
</div>
</div>
<div style="height:10px;"></div>
<div class="row">
<div class="col-lg-3">
<label style="position:relative; top:7px;">Product:</label>
</div>
<div class="col-lg-8">
<?php
$query_produk = "SELECT product FROM testingdata";
$sql = mysqli_query($conn, $query_produk);
$array = array();
while ($row_product = mysqli_fetch_assoc($sql)) {
$array [ $row_product['product'] ] = $row_product['product'];
}
?>
<select id="product" name="product" class="form-control">
<option value="">-Pilih product-</option>
<?php
foreach ($array as $product=>$product) {
$selected = '';
if ($product == $row['product']) {
$selected = 'selected';
}
echo "<option " . $selected . " value='$product'>$product</option>";
}
?>
</select>
</div>
</div>
<div style="height:10px;"></div>
<div class="row">
<div class="col-lg-3">
<label style="position:relative; top:7px;">Color:</label>
</div>
<div class="col-lg-8">
<input type="text" name="color" class="form-control" value="<?php echo $row['color']; ?>">
</div>
</div>
<div style="height:10px;"></div>
<div class="row">
<div class="col-lg-3">
<label style="position:relative; top:7px;">User:</label>
</div>
<div class="col-lg-8">
<input type="text" name="inisial" class="form-control" value="<?php echo $row['inisial']; ?>">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
<button type="submit" class="btn btn-warning"><span class="glyphicon glyphicon-check"></span> Save</button>
</div>
</form>
</div>
</div>
</div>
<!-- /.modal -->
我希望我能搜索到所有的列。
确保你有"search"关键
$(document).ready(function () {
$('#example').DataTable({
search: {
return: true,
},
});
});
文档