...
 
Commits (2)
<?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();
?>
......@@ -26,7 +26,7 @@
function contact()
{
var xhr=new XMLHttpRequest(); // creation de l'objet
xhr.open('POST','test.php', true);
xhr.open('POST','/assets/php/bddmanager.php', true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.onreadystatechange=function()
......@@ -76,7 +76,7 @@
function getnbusers()
{
var xhr=new XMLHttpRequest(); // creation de l'objet
xhr.open('POST','test.php', true);
xhr.open('POST','/assets/php/bddmanager.php', true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.onreadystatechange=function()
......
assets/img/safetybox.png

53.4 KB | W: | H:

assets/img/safetybox.png

29.1 KB | W: | H:

assets/img/safetybox.png
assets/img/safetybox.png
assets/img/safetybox.png
assets/img/safetybox.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -16,9 +16,6 @@ if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ( isset($_POST['action']))
{
if ($_POST['action'] == "print")
......
favicon.ico

5.3 KB | W: | H:

favicon.ico

14.7 KB | W: | H:

favicon.ico
favicon.ico
favicon.ico
favicon.ico
  • 2-up
  • Swipe
  • Onion skin
<!DOCTYPE html>
<html lang="fr">
<head>
<link rel="shortcut icon" href="/favicon.ico">
<link rel='mask-icon' href='/favicon.ico' color='blue'>
<!-- <link rel="shortcut icon" href="/favicon.ico">
<link rel='mask-icon' href='/favicon.ico' color='blue'> -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#0069b4">
<meta name="msapplication-TileColor" content="#0069b4">
<meta name="theme-color" content="#ffffff">
<!-- Required meta tags -->
<meta charset="utf-8">
......@@ -51,7 +61,7 @@
}
}
// envoie des donnees au serveur
// envoie des donnees (donnees en POST) au serveur php
xhr.send("request="+encodeURIComponent(document.getElementById("searchid").value));
return false;
}
......