这是我的javascript和标志
<script type="text/javascript">
$(document).ready(function() {
var dataTable = $("#example").DataTable( {
processing: true,
bSort: false,
serverSide: true,
iDisplayLength: 10,
"ajax": {
"url": "json/j-t.php",
"type": "POST"
},
} );
$("#example_filter").css("display","none"); // hiding global search box
$(".example-search-input").on("keyup click change", function () {
var ixoh =$(this).attr("id"); // getting column index
var vxoh =$(this).val(); // getting search input value
dataTable.columns(ixoh).search(vxoh).draw();
if(ixoh != null || ixoh != null){ dataTable.columns(ixoh).search(vxoh).draw(); };
} );
</script>
下面是j-t.php文件
$sql = "SELECT *";
$sql.=" FROM info WHERE type='1' AND sold='0'";
$query=mysqli_query($conn, $sql) or die;
$totalData = mysqli_num_rows($query);
$totalFiltered = $totalData;
$data = array();
while( $row=mysqli_fetch_array($query) ) { // preparing an array
$nestedData=array();
$nestedData[] = $row["types"];
$nestedData[] = $row["country"];
$nestedData[] = $row["infos"];
$nestedData[] = $row["price"];
$nestedData[] = $row["email"];
$data[] = $nestedData;
}
$json_data = array(
"draw" => intval( $requestData['draw'] ),
"recordsTotal" => intval( $totalData ),
"recordsFiltered" => intval( $totalFiltered ),
"data" => $data
);
echo json_encode($json_data);
这是我数据库
SELECT * FROM `info` WHERE `country` LIKE 'CA' ORDER BY `date_added` DESC
我需要添加数据表,就像国家名称CA US DE GB等...我喜欢在数据表国家行中添加标志和国家名称
2条答案
按热度按时间9udxz4iz1#
您可以从这样的地方下载所有SVG标志...
https://observablehq.com/@slattery/iso-3166-svg-flags
...然后使用一个
ALTER TABLE info ADD COLUMN
查询,后跟一组UPDATE
查询,向数据库中添加一列,其中包含与标记文件关联的名称。PHP逻辑(或Twig、Blade,或您正在使用的任何东西)会将该名称转换为一个实际的
<img>
标记,以包含在表中。wfveoks02#
您可以按如下所述使用列呈现:https://datatables.net/examples/advanced_init/column_render.html
在您的情况下,这可能是这样的: