My first table
My first table
I'm coding my first datatable but it's doesnt work, no error in console too. Hope you can help me please.
here is my code :
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Clients</title>
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="materialize/css/materialize.min.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="materialize/css/home.css"/>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="materialize/js/materialize.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#client').DataTable();
} );
</script>
</head>
<body>
<div class="row">
<div class="col s4"></div>
<div class="col s4 "><h1>Mes clients</h1></div>
<div class="col s4"></div>
</div>
<div class="row">
<div class="col s2"></div>
<div class="col s4">
<a href="addclient.php" class="btn-floating btn-large waves-effect waves-light red tooltipped" data-position="right" data-delay="50" data-tooltip="Ajouter un client"><i class="material-icons">add</i></a>
</div>
</div>
<div class="row">
<form method="post" action="search.php">
<div class="col s1"></div>
<div class="input-field col s3">
<i class="material-icons prefix">search</i>
<input id="icon_prefix" type="text" class="validate" name="search">
<label for="icon_prefix">Recherche</label>
</div>
</form>
</div>
<
table id="client" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>Nom de shop</th>
<th>Télephone</th>
<th>Email</th>
<th>Ville</th>
<th>Code Postale</th>
<th>Statut</th>
<th>Vendeur</th>
<th>Date de création</th>
</tr>
<tbody>
<?php
include('connectbdd.php');
$order = "";
$query = "select * from client ORDER BY '$order'";
$decode = mysqli_query($_SESSION['connect'],"SET NAMES utf8");
$result = mysqli_query($_SESSION['connect'], $query);
while ($data = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>".$data['nom_shop']."</td>";
echo "<td>".$data['tel']."</td>";
echo "<td>".$data['mail']."</td>";
echo "<td>".$data['ville']."</td>";
echo "<td>".$data['cp']."</td>";
switch ($data['statut']) {
case 0:
echo "<td>Pas de statut</td>";
break;
case 1:
echo "<td>Pas intéressé</td>";
break;
case 2:
echo "<td>Peu intéressé</td>";
break;
case 3:
echo "<td>intéressé</td>";
break;
case 4:
echo "<td>Très intéressé</td>";
break;
}
echo "<td>".$data['vendeur']."</td>";
echo "<td>".$data['date_creation']."</td>";
echo "<td>
<a class='waves-effect waves-light btn red' href='detail.php?Id=$data[id_client]'>détails</a>
</td>";
echo "</tr>";
;
}
mysqli_free_result ($result);
?>
</body>
</html>
Replies
Happy to help. Please link to a test page showing the issue, per the forum rules.
Information on how to create a test page, if you can't provide a link to your own page can be found here.
Thanks,
Allan