There is the code for my table with all steps followd for activeting DataTable
<!doctype html>
<html>
<head>
<title>Upload to DB</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
<link href="https://cdn.datatables.net/v/dt/jq-3.6.0/dt-1.13.4/datatables.min.css" rel="stylesheet"/>
<script src="https://cdn.datatables.net/v/dt/jq-3.6.0/dt-1.13.4/datatables.min.js"></script>
<script type="text/javascript" src="autosearch.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.dataTables.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$('#myTable').DataTable();
});
</script>
<table class="table table-bordered table-striped" style="margin-top: 50px;" id="myTable">
<tr>
<?php
$select="select * from videos";
$result=mysqli_query($con,$select);
?>
<thead class="sortable" style="text-align: center;">
<tr>
<th> Id</th>
<th> Video </th>
<th> Názov </th>
<th> Autor </th>
<th> Tagy </th>
<th> Žáner </th>
<th> Hodnotenie </th>
<th> Rozlíšenie videa </th>
<th> Počet Snímkov </th>
<th> Dĺžka videa</th>
<th> Dátum Vytvorenia </th>
</tr>
</thead>
<?php while($rows=mysqli_fetch_assoc($result))
{
$location = $rows['location'];
?>
<tbody style="text-align: center;">
<tr>
<td><?php echo $rows['id']; ?></td>
<td><?php echo "<video src='".$location."' controls width='200px' height='200px' ></video>"; ?></td>
<td><?php echo $rows['FileName']; ?></td>
<td><?php echo $rows['author']; ?></td>
<td><?php echo $rows['tags']; ?></td>
<td><?php echo $rows['genre']; ?></td>
<td><?php echo $rows['rating']; ?></td>
<td><?php echo $rows['ImageSize']; ?></td>
<td><?php echo $rows['VideoFrameRate']; ?></td>
<td><?php echo $rows['MediaDuration']; ?></td>
<td><?php echo $rows['CreateDate']; ?></td>
</tr>
</tbody>
<?php
}
?>
</table>
</body>
</html>
Do you know of any method, to add a sorting method to the Top columns for the data SELECTED from my local database table ?
Im trying to create orting out for columns in HTML table with PHP values selected from database.
Im getting this error: DataTables warning: table id=myTable - Incorrect column count. For more information about this error, please see http://datatables.net/tn/18
There is also a photo of files i downloaded
There is HTML source view for the table.