From 20c93593d8a26a127b1fd9ca385d482c7307ead7 Mon Sep 17 00:00:00 2001 From: Juan Date: Wed, 2 Feb 2022 10:54:13 +0100 Subject: [PATCH] =?UTF-8?q?bases=20de=20donn=C3=A9es=20suite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- b1-bak/session2/blog/admin.php | 88 +++++++++++++++++++++++++++ b1-bak/session2/blog/index.php | 132 +++++++++++++++++++++++++++++++++++++++++ b3-dev/api/session1/server.js | 10 ++-- 3 files changed, 225 insertions(+), 5 deletions(-) create mode 100644 b1-bak/session2/blog/admin.php create mode 100644 b1-bak/session2/blog/index.php diff --git a/b1-bak/session2/blog/admin.php b/b1-bak/session2/blog/admin.php new file mode 100644 index 0000000..51463df --- /dev/null +++ b/b1-bak/session2/blog/admin.php @@ -0,0 +1,88 @@ + + + connect_errno) { + $class_de_la_page = "error"; + } + ?> + + <?php echo $titre_de_la_page ?> + + + +

+ Il manque quelque chose ! "; + } + elseif(!empty($titre_de_article)) { + $resultat = $mysqli->query(" + INSERT INTO `article` (`id_article`, `titre`, `contenu`, `date`) + VALUES (NULL, '".$titre_de_article."', '".$contenu_de_article." ', NOW()); + "); + if($resultat) { + echo "
Article enregistré !
"; + $titre_de_article = ""; + $contenu_de_article = ""; + } + } + ?> +
+ +
+ +
+ +
+ +
+ +
+ + connect_errno) + { + echo "Échec lors de la connexion à MySQL : (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; + } + else + { + $resultat = $mysqli->query('SELECT * FROM `article`'); + echo "
".$resultat->num_rows." articles dans la base"; + while ( $ligne_de_resultat = $resultat->fetch_array(MYSQLI_ASSOC) ) + { + echo "

".$ligne_de_resultat['titre']."

"; + } + } + ?> + + \ No newline at end of file diff --git a/b1-bak/session2/blog/index.php b/b1-bak/session2/blog/index.php new file mode 100644 index 0000000..e9b2dc7 --- /dev/null +++ b/b1-bak/session2/blog/index.php @@ -0,0 +1,132 @@ + + + + Mon Blog + + + +

Mon Blog

+ +
+ connect_errno) { + echo "Échec lors de la connexion à MySQL : (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; + } + //sinon on est connecté + else { + echo "connecté à "; + } + echo $mysqli->host_info . "\n"; + + // aller chercher le premier article dans la table article + // SELECT * FROM `article` + // appeler la méthode query de mysqli + // https://www.php.net/manual/fr/mysqli.quickstart.statements.php + $resultat = $mysqli->query('SELECT * FROM `article`'); + // récupérer le premier l'article. + $ligne_de_resultat = $resultat->fetch_array(MYSQLI_ASSOC); + // afficher en deboguage mon resultat + /* + echo "
";
+            print_r($ligne_de_resultat);
+            echo "
"; + */ + // afficher l'article + ?> +

+

+
publié le
+
+
+        
+    
+
+
+ +
+ Vous devez saisir un pseudo
"; + } + ?> + +
+ +
+ Vous devez saisir un email valide"; + } + ?> + +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/b3-dev/api/session1/server.js b/b3-dev/api/session1/server.js index 08c0855..6e0230e 100644 --- a/b3-dev/api/session1/server.js +++ b/b3-dev/api/session1/server.js @@ -33,13 +33,13 @@ const server = http.createServer(function (request, response) { { console.log(request.method); console.log(parsedUrl.query.address); - getLatLong(parsedUrl.query.address); + getLatLong(parsedUrl.query.address, response); json_response(200,{status : "active"},response); } }); -server.listen(8080); +server.listen(8081); -function getLatLong(address) { +function getLatLong(address, response) { let result = null; /* Create a new promise and send geocoding request */ @@ -58,7 +58,7 @@ function getLatLong(address) { promise.then((data) => { console.log(data.features[0].properties); - getWeatherAtLatLong(data.features[0].properties.lat, data.features[0].properties.lon); + getWeatherAtLatLong(data.features[0].properties.lat, data.features[0].properties.lon, response); }, (err) => { if (!err.canceled) { console.log(err); @@ -66,6 +66,6 @@ function getLatLong(address) { }); } -function getWeatherAtLatLong(lat,long) { +function getWeatherAtLatLong(lat,long, response) { console.log('getWeatherAtLatLong('+lat+','+long+')'); }