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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
<html>
<style type="text/css">
textarea#contenu{
height: 20px;
width:10%;
}
</style>
<!-- PHP_SELF lors de la validation rememorise les variables -->
<form name="unform" action="<?$_SERVER['PHP_SELF'];?>" method="post">
tables : <BR>
<SELECT NAME="tables" MULTIPLE SIZE="8" onchange="document.unform.submit();">
<?php
/*récupére le nom du schema envoyé par tigra menu voir menu_items.js*/
$nom1 = $_GET['schemaInput'];
$Schema=$nom1;
/* Connection postgres */
$conn = pg_pconnect("host=localhost port=5432 dbname=eco
user=postgres password=postgres");
if (!$conn) {
echo "Une erreur s'est produite.\n";
exit;
}
/* AFFICHE LES TABLES DU SCHEMA et les mets dans une liste */
$requete_tables_du_schema ="select distinct(relname) from pg_attribute, pg_class, pg_namespace where
attnum>0 and attrelid=pg_class.oid and relnamespace=pg_namespace.oid and nspname="."'".$Schema."'";
$resultat = pg_query($conn,$requete_tables_du_schema);
$tableau = array();
while($ligne = pg_fetch_assoc ($resultat))
{
$tableau[] = $ligne; /* memorisation des tables du schema dans un tableau */
}
?>
tables : <BR>
<?php
/* lit le tableau et affiche les schemas */
foreach ($tableau as $tab1)
{
$sel=isset($_POST['tables'])&&($tab1[relname]==$_POST['tables'])?'selected="selected"':' ';
echo "<OPTION VALUE=".$tab1["relname"]." ".$sel." >".$tab1["relname"]."</option>";
}
?>
</SELECT>
<!-- espace presentation -->
Chercher Pour :
<?php
/* MEMORISE Le click de la selection de la table */
if(isset($_POST["tables"])){
$tavariable=$_POST["tables"];
}
?>
<?php
/* affiche le resultat dans un tableau */
include('cmb_champs_table.php');
?>
<?php
/* AFFICHE LES criteres > < = etc ... */
include('criteres.php');
?>
<TEXTAREA id="contenu" NAME="contenu" COLS=1 ROWS=1>
<?php
/* recupere le contenu du textarea */
if(isset($_POST["contenu"]))
echo $_POST["contenu"];
?>
</TEXTAREA>
<!-- Validation du bouton -->
<INPUT TYPE="submit" NAME="Valider" VALUE="OK">
<INPUT TYPE="submit" NAME="Export" VALUE="Export">
</FORM>
<?php
if(isset($_POST['Export']))
{
include('test31.php');
}
/* récupération des paramétres */
if(isset($_POST['Valider']))
{
/* pour Debug
echo "tables ",$_POST['tables'];
echo "<br>";
echo "Valeur du champ : ",$_POST['cmb_champs_table'];
echo "<br>";
echo "Valeur du textarea : ",$_POST['contenu'];
echo "<br>";
echo "Valeur du criteres : ",$_POST['criteres'];
echo "<br>";
*/
$criteres =$_POST['criteres'];
$ChoixTable =$_POST['tables'];
$ChoixChamp =$_POST['cmb_champs_table'];
$Choixvaleur=$_POST['contenu'];
$nomschema = $_GET['schemaInput'];
if ($criteres=="Egal")
{
$param_requete="select * from ".$nomschema.".".$ChoixTable." where ".$ChoixChamp."=". "'" .$Choixvaleur."'". " limit 500 ";
}
if ($criteres=="Supérieur")
{
$param_requete="select * from ".$nomschema.".".$ChoixTable." where ".$ChoixChamp.">". "'" .$Choixvaleur."'". " limit 500 ";
}
if ($criteres=="Inférieur")
{
$param_requete="select * from ".$nomschema.".".$ChoixTable." where ".$ChoixChamp."<". "'" .$Choixvaleur."'". " limit 500 ";
}
if ($criteres=="Supérieur ou égal")
{
$param_requete="select * from ".$nomschema.".".$ChoixTable." where ".$ChoixChamp.">=". "'" .$Choixvaleur."'". " limit 500 ";
}
if ($criteres=="Inférieur ou égal")
{
$param_requete="select * from ".$nomschema.".".$ChoixTable." where ".$ChoixChamp."<=". "'" .$Choixvaleur."'". " limit 500 ";
}
if ($criteres=="Entre")
{
/* between entre a faire on mettre 12-15 */
$findme = '-';
$pos = strpos( $Choixvaleur, $findme);
if ($pos === false)
{
echo "The string '$findme' was not found in the string ";
}
else
{
// on remplace - par and
$between=str_replace('-',' and ' , $Choixvaleur);
echo "<script>alert(\"$Choixvaleur\")</script>";
}
$param_requete="select * from ".$nomschema.".".$ChoixTable." where ".$ChoixChamp." between ". "'" .$Choixvaleur."'". " limit 500 ";
echo "<script>alert(\"$param_requete\")</script>";
}
// Affichage dans un tableau
include('tableau.php');
}
?>
</html> |