Commit 076c014f authored by Cedrick Copol's avatar Cedrick Copol

Thème

parent a6e341c3
Pipeline #243 failed with stage
in 1 second
<?php
// mysql -uledoc -p
// create table personne(nom TEXT, prenom TEXT, description TEXT, FULLTEXT(nom,prenom)) ENGINE=MyISAM;
// quit
header("Content-Type: application/json; charset=UTF-8");
// database
$servername = "localhost";
$username = "ledoc";
$password = "safetybox";
$dbname = "sinistres";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ( isset($_POST['action']))
{
if ($_POST['action'] == "count")
{
$sql = "SELECT id FROM personne";
if ($result = $conn->query($sql) ) {
$json = '{"resultat": "'.$result->num_rows.'"}'; // nombre de lignes
echo $json;
}
$result->close();
}
elseif ($_POST['action'] == "print")
{
$sql = "SELECT * FROM personne";
if ($result = $conn->query($sql) ) {
// $rows=array();
// while($r = $result->fetch()))
// {
// $rows[]=$r;
// }
// header("Content-type:application/json");
// echo json_encode($rows);
$json = '{"resultat": [';
$nb = 0;
while($row = $result->fetch())
{
if ($nb != 0){ $json.=",";}
$json.='{"id": "'.$row['id'].'" ,"nom" : "'.$row['nom'].'","prenom" : "'.$row['prenom'].'","desc" : "'.$row['description'].'","lieu" : "'.$row['lieu'].'", "heure" : "'.$row['heure'].'"}';
$nb++;
}
$json.=']}';
echo $json;
}
$result->close();
}
}
// Close the database
$conn->close();
?>
......@@ -68,13 +68,141 @@
<body>
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0">
<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="/">SafetyBox</a>
<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
<ul class="navbar-nav px-3">
<li class="nav-item text-nowrap">
<a class="nav-link" href="#">Sign out</a>
</li>
</ul>
</nav>
<div class="container-fluid">
<div id="personnerow">
</div>
<div class="col-md-7 d-flex justify-content-end">
<button onclick="contact()" class="btn btn-primary">Envoyer</button>
<div class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#">
<span data-feather="home"></span>
Dashboard <span class="sr-only">(current)</span>
</a>
</li>
<!-- <li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="file"></span>
Orders
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="shopping-cart"></span>
Products
</a>
</li> -->
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="users"></span>
SafetyBoxes
</a>
</li>
<!-- <li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="bar-chart-2"></span>
Reports
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="layers"></span>
Integrations
</a>
</li> -->
</ul>
<!-- <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Saved reports</span>
<a class="d-flex align-items-center text-muted" href="#">
<span data-feather="plus-circle"></span>
</a>
</h6> -->
<!-- <ul class="nav flex-column mb-2">
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="file-text"></span>
Current month
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="file-text"></span>
Last quarter
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="file-text"></span>
Social engagement
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="file-text"></span>
Year-end sale
</a>
</li>
</ul> -->
</div>
</nav>
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
<!-- <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
<h1 class="h2">Dashboard</h1>
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group mr-2">
<button class="btn btn-sm btn-outline-secondary">Share</button>
<button class="btn btn-sm btn-outline-secondary">Export</button>
</div>
<button class="btn btn-sm btn-outline-secondary dropdown-toggle">
<span data-feather="calendar"></span>
This week
</button>
</div>
</div> -->
<!-- <canvas class="my-4" id="myChart" width="900" height="380"></canvas> -->
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
<h1>Liste inscrits</h1>
<div class="btn-toolbar mb-2 mb-md-0">
<button class="btn btn-sm btn-outline-secondary" id="searchid" onclick="contact()">
Rafraîchir
</button>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr> <th COLSPAN=3></th> <th COLSPAN=2>Inscription</th></tr>
<tr>
<th>#</th>
<th>Nom</th>
<th>Prénom</th>
<th>Lieu</th>
<th>Heure</th>
</tr>
</thead>
<tbody id="personnerow">
<!--Print the resultSet data with a for loop here-->
</tbody>
</table>
</div>
</main>
</div>
</div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment