Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Projet_idaw
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Liang Wu
Projet_idaw
Commits
ede81403
Commit
ede81403
authored
Apr 02, 2020
by
Raulin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
affichage aliments
parent
0da7988e
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
150 additions
and
364 deletions
+150
-364
afficher_aliments.php
DataTables/api/afficher_aliments.php
+16
-0
ajouter_aliment.php
DataTables/api/ajouter_aliment.php
+12
-0
bdd.php
DataTables/api/bdd.php
+13
-0
template.php
DataTables/api/template.php
+34
-0
aliments.php
aliments.php
+33
-355
afficher_aliments.php
api/afficher_aliments.php
+8
-3
template.php
api/template.php
+3
-6
test.php
test.php
+31
-0
No files found.
DataTables/api/afficher_aliments.php
0 → 100644
View file @
ede81403
<?php
require_once
(
"template.php"
);
$requete
=
"SELECT * FROM ALIMENTS"
;
$result
=
$mysqli
->
query
(
$requete
);
$aliments
=
$result
->
fetch_all
();
$rep
=
reponse_json
(
$aliments
);
echo
$rep
[
'result'
][
0
][
1
];
// echo json_encode($aliments);
// echo json_encode($aliments[0][1]);
// reponse_json($success, $data);
\ No newline at end of file
DataTables/api/ajouter_aliment.php
0 → 100644
View file @
ede81403
<?php
require_once
(
"template.php"
);
if
(
isset
(
$_POST
[
"aliment"
])
&&
isset
(
$_POST
[
"cat"
])){
$requete
=
"INSERT INTO `ALIMENTS` (`ID_ALIMENT`,`NAME_ALIMENT`, `TYPE_ALIMENT`) VALUES (NULL, '"
.
$_POST
[
'aliment'
]
.
"', '"
.
$_POST
[
'cat'
]
.
"')"
;
$mysqli
->
query
(
$requete
);
$msg
=
"L'aliment a bien été ajouté"
;
}
else
{
$msg
=
"Il manque des informations"
;
}
echo
$msg
;
DataTables/api/bdd.php
0 → 100644
View file @
ede81403
<?php
try
{
DEFINE
(
'DB_USERNAME'
,
'charlotte.raulin'
);
DEFINE
(
'DB_PASSWORD'
,
'MIZWqEaY'
);
DEFINE
(
'DB_HOST'
,
'127.0.0.1'
);
DEFINE
(
'DB_DATABASE'
,
'charlotte_raulin'
);
$mysqli
=
new
mysqli
(
DB_HOST
,
DB_USERNAME
,
DB_PASSWORD
,
DB_DATABASE
);
$retour
[
"success"
]
=
true
;
}
catch
(
Exception
$e
){
$retour
[
"success"
]
=
false
;
};
?>
\ No newline at end of file
DataTables/api/template.php
0 → 100644
View file @
ede81403
<?php
header
(
'Content-Type: application/json'
);
//pour que le navigateur l'affiche dans le format json
include
(
'bdd.php'
);
function
reponse_json
(
$data
){
$array
[
'result'
]
=
$data
;
echo
json_encode
(
$data
);
}
// echo json_encode($aliments);
// $retour = array();
// $retour["aliments"]= array();
// $retour["aliments"][0]["id"] = 1;
// $retour["aliments"][0]["name"] = "Pomme";
// $retour["aliments"][0]["type"] = "Fruit";
// $retour["aliments"][1]["id"] = 2;
// $retour["aliments"][1]["name"] = "Poire";
// $retour["aliments"][1]["type"] = "Fruit";
// `LOGIN`
\ No newline at end of file
aliments.php
View file @
ede81403
This diff is collapsed.
Click to expand it.
api/afficher_aliments.php
View file @
ede81403
<?php
includ
e
(
"template.php"
);
require_onc
e
(
"template.php"
);
$requete
=
"SELECT * FROM ALIMENTS"
;
$result
=
$mysqli
->
query
(
$requete
);
$aliments
=
$result
->
fetch_all
();
json_encode
(
$aliments
);
reponse_json
(
$aliments
);
// reponse_json($success, $data);
\ No newline at end of file
api/template.php
View file @
ede81403
...
...
@@ -2,14 +2,11 @@
header
(
'Content-Type: application/json'
);
//pour que le navigateur l'affiche dans le format json
include
(
'bdd.php'
);
// function reponse_json($success, $data, $msgErreur=NULL){
// $array['success']=$_success;
// $array['msg']=$msgErreur;
// $array['result']=$data;
function
reponse_json
(
$data
){
// echo json_encode($msg,
$data);
echo
json_encode
(
$data
);
//
}
}
...
...
test.php
0 → 100644
View file @
ede81403
<!-- <head>
<script type="text/javascript">
$(document).ready(function() {
Alert.alert("func");
$.getJSON('https://eden.imt-lille-douai.fr/~charlotte.raulin/Projet/api/afficher_aliments.php',
function(json){
Alert.alert("get");
for (let i = 0; pas < 2; pas++){
Alert.alert("hey");
$('#test').append(json[i][1]+'<br>'+json[i][2]);
}
};
);
} );
</script>
</head>
<div id="test">hallo</div>
<script type="text/javascript">
function getAliments(){
$.getJSON('https://eden.imt-lille-douai.fr/~charlotte.raulin/Projet/api/afficher_aliments.php',
function(json){
for (let i = 0; pas < 2; pas++){
alert(json[1][1]);
$('#test').append(json[i][1]+'<br>'+json[i][2]);
}
};
);
}
getAliments();
</script> -->
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment