-
Notifications
You must be signed in to change notification settings - Fork 0
/
request.php
43 lines (37 loc) · 1.05 KB
/
request.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
// afin de recuperer le nom du table :D
$s=$_SERVER['HTTP_REFERER'];
$a= strrpos($s,"/");
$b= strrpos($s,".php");
$table = substr($s,$a+1,$b-$a-1);
// verifier si le choix de trie est fait ou non ;)
if(!isset($_GET['chek'])) $sort=" ";
else $sort="ORDER BY departement ASC";
echo "<link rel=\"stylesheet\" href=\"style1.css\" />" ;
try{
$bdd2= new PDO('mysql:host=localhost;dbName=hopital', 'root', '');
}
catch (PDOException$e) { print"Erreur : " . $e->getMessage();die(); }
$bdd2->query("USE hopital");
if((isset($_GET["text"]))AND(!empty($_GET["text"]))){
$reponse= $bdd2->query('select * from '.$table.' WHERE nom LIKE "'.$_GET["text"].'%" or nom LIKE "'.'% '.$_GET["text"].'%"'.$sort);
}
else{
$reponse= $bdd2->query('select * from '.$table.' '.$sort);
}
if($reponse){
$n=$reponse->columnCount();
echo "<table> <tr>";
for ($i=0;$i<$n;$i++){
$meta = $reponse->getColumnMeta($i);
echo "<td>".$meta['name'];
}
foreach($reponse as $res)
{
echo "<tr>";
for ($i=0;$i<$n;$i++){
echo "<td>".$res[$i];
}
}
echo "</table>";}
?>