Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gaetan Carabetta
projet_nf17_p19_tdg1_groupe2
Commits
56c1d002
Commit
56c1d002
authored
Jun 19, 2019
by
Osvaldo Valdivia Salas
Browse files
Upload New File
parent
8e5a493a
Changes
1
Hide whitespace changes
Inline
Side-by-side
application/statAnimal.php
0 → 100644
View file @
56c1d002
<html>
<head>
<title>
Exercice
</title>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"style.css"
>
</head>
<body>
<?php
$vHost
=
'tuxa.sme.utc'
;
$vPort
=
'5432'
;
$vData
=
'dbbdd0p117'
;
$vUser
=
'bdd0p117'
;
$vPass
=
'LpIHl1sZ'
;
try
{
$vConn
=
new
PDO
(
"pgsql:host=
$vHost
;port=
$vPort
;dbname=
$vData
"
,
$vUser
,
$vPass
);
}
catch
(
PDOException
$e
){
echo
"Erreur de connection '
$e
'"
;
}
$idAnimal
=
$_POST
[
'idAnimal'
];
if
(
$idAnimal
==
""
){
echo
"Il faut dire quel animal"
;
header
(
'Location: http://tuxa.sme.utc/~bdd0p117/animal.php'
);
}
?>
<h1>
Quantité de médicament prescrite à un animal
</h1>
<table
border=
"1"
>
<tr>
<th>
Medicament
</th>
<th>
Somme
</th>
</tr>
<?php
try
{
$vSql
=
"SELECT P.nomMolec as medicament, COUNT(*) as quantite_prescrite
FROM Posologie P JOIN Traitement T on P.traitement=T.idTraitement
WHERE T.idAnimal='
$idAnimal
'
GROUP BY P.nomMolec;
"
;
$vSt
=
$vConn
->
prepare
(
$vSql
);
$vSt
->
execute
();
while
(
$vResult
=
$vSt
->
fetch
(
PDO
::
FETCH_BOTH
))
{
echo
'<tr>'
;
echo
"<td>
$vResult[0]
</td>"
;
echo
"<td>
$vResult[1]
</td>"
;
echo
'</tr>'
;
}
}
catch
(
PDOException
$e
){
echo
"Erreur de requete '
$e
'"
;
}
?>
</table>
<h1>
Nombre des comprimés prescrit à un animal
</h1>
<table
border=
"1"
>
<tr>
<th>
Medicament
</th>
<th>
Somme
</th>
</tr>
<?php
try
{
$vSql
=
"SELECT P.nomMolec,SUM(P.duree*P.nbJourna) FROM Posologie P
JOIN Traitement T ON P.traitement=T.idTraitement WHERE
T.idAnimal='
$idAnimal
' group by P.nomMolec;
"
;
$vSt
=
$vConn
->
prepare
(
$vSql
);
$vSt
->
execute
();
while
(
$vResult
=
$vSt
->
fetch
(
PDO
::
FETCH_BOTH
))
{
echo
'<tr>'
;
echo
"<td>
$vResult[0]
</td>"
;
echo
"<td>
$vResult[1]
</td>"
;
echo
'</tr>'
;
}
}
catch
(
PDOException
$e
){
echo
"Erreur de requete '
$e
'"
;
}
?>
</table>
</body>
</html>
Write
Preview
Supports
Markdown
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