Valid XHTML    Valid CSS2    

Listing du fichier dscbaz.php

 

00001     <?php
00002     error_reporting
(E_ALL | E_NOTICE ) ;
00003     include(
"../std.php") ;
00004     
$tit
= "Visualisation d'une table MySql" ;
00005     
debutPage
($tit) ;
00006     
blockquote() ;
00007     
debutSection() ;
00008     
00009     
$nombase
= "" ;
00010     
$nomtable
= "" ;
00011     
$err
= 0 ;
00012     
00013     if (isset(
$_POST
["nombase"])) { $nombase = $_POST["nombase"] ; } ;
00014     if (isset(
$_POST
["nomtable"])) { $nomtable = $_POST["nomtable"] ; } ;
00015     if (isset(
$_POST
["numdeb"])) { $numdeb = $_POST["numdeb"] ; } ;
00016     if (isset(
$_POST
["nbenr"])) { $nbenr = $_POST["nbenr"] ; } ;
00017     
00018     if (
$nombase
== "") {
00019      echo
"Aucun nom de base fournie, rien à faire. " ;
00020     
$err++;
00021     } ;
# fin de si
00022     
00023     
if (
$nomtable == "") { ;
00024      echo
"Aucun nom de table fourni, rien à faire. " ;
00025     
$err++;
00026     } ;
# fin de si
00027     
00028     
if (
$err==0) {
00029     
00030     
h1
("Visualisation de la table $nomtable de la base MySql nommée $nombase") ;
00031     
$numfin
= $numdeb + $nbenr - 1 ;
00032     
h2
("&nbsp; &nbsp; enregistrements demandés : de $numdeb à $numfin") ;
00033     
blockquote() ;
00034     
00035     
#########################################################
00036     
00037     
$res1
= @mysql_connect("localhost","anonymous","anonymous") or die("problème de connexion à forge") ;
00038     
$res2
= @mysql_query("use $nombase") ;
00039      if (!
$res2) {
00040     
p() ;
00041      echo
"La base "
.b($nombase)." n'existe pas ou alors vous n'avez pas les droits suffisants pour y accéder." ;
00042     
finp() ;
00043      } else {
00044     
$res3
= mysql_query("select * from $nomtable") ;
00045     
$nbvus
= 0 ;
00046     
00047     
$rese
= mysql_query("select count(*) from $nomtable") or die( mysql_error() ) ;
00048     
$ligr
= mysql_fetch_array($rese) ;
00049     
$nbe
= $ligr["count(*)"] ;
00050     
00051     
h2
("Description de la table (elle contient $nbe enregistrements)") ;
00052     
$res4
= mysql_query("describe $nomtable") ;
00053     
$nl
= 0 ;
00054     
table
(1,8,"collapse") ;
00055     
00056     
tr() ;
00057     
th
() ; echo "Numéro" ; finth() ;
00058     
th
() ; echo "Nom du champ" ; finth() ;
00059     
th
() ; echo "Type du champ" ; finth() ;
00060     
th
() ; echo "Null" ; finth() ;
00061     
th
() ; echo "Index" ; finth() ;
00062     
th
() ; echo "Default" ; finth() ;
00063     
/*
00064      th() ; echo "? " ; finth() ;
00065      th() ; echo "? " ; finth() ;
00066      th() ; echo "? " ; finth() ;
00067      th() ; echo "? " ; finth() ;
00068      th() ; echo "? " ; finth() ;
00069      th() ; echo "? " ; finth() ;
00070     */
00071     
fintr() ;
00072     
00073     
00074      while (
$ligr
=mysql_fetch_array($res4)) {
00075     
$nl++ ;
00076     
tr() ;
00077     
$nc
= count($ligr) ;
00078     
/*
00079     pre("invisible") ;
00080     echo" ligne $nl \n" ;
00081     print_r($ligr) ;
00082     finpre() ;
00083     */
00084     
td
("R") ; echo $nl ; fintd() ;
00085     
$nomchamp
[$nl] = $ligr[0] ;
00086     
$ic
= 0 ;
00087     
#while ($ic < $nc) {
00088     
while (
$ic < 5) { # 5 mis "à la main"
00089     
if (isset(
$ligr[$ic] ) ) {
00090     
$elt
= $ligr[$ic] ;
00091      if (
"(
$elt)" == "()") {
00092     
$elt
= " &nbsp; " ;
00093      } ;
# fin de si
00094     
td
() ; echo $elt ; fintd() ;
00095      } ;
# fin de si
00096     
$ic++ ;
00097      } ;
# fin de tant que
00098     
fintr() ;
00099      } ;
# fin de tant que
00100     
fintable() ;
00101     
00102     
00103     
h2
("Liste des enregistrements") ;
00104     
00105     
$nb
= 0 ;
00106     
table
(1,5,"collapse") ;
00107     
00108     
tr() ;
00109     
th
() ; echo "Numéro" ; finth() ;
00110     
$il
= 1 ;
00111      while (
$il
<= $nl) {
00112     
th
() ; echo $nomchamp[$il] ; finth() ;
00113     
$il++;
00114      } ;
# fin de tant que
00115     
fintr() ;
00116     
00117      while (
$ligr
=mysql_fetch_array($res3)) {
00118     
$nb++ ;
00119      if (
$nb
>=$numdeb) {
00120      if (
$nb
<=$numfin) {
00121     
$nbvus++ ;
00122     
tr() ;
00123     
td
("R") ; echo $nb ; fintd() ;
00124     
$ic
= 0 ;
00125      while (
$ic
< $nl) {
00126     
td
() ; echo $ligr[$ic] ; fintd() ;
00127     
$ic++ ;
00128      } ;
# fin de tant que
00129     
fintr() ;
00130      } ;
# fin de si <= numfin
00131     
} ; # fin de si >= numdeb
00132     
} ; # fin de tant que
00133     
fintable() ;
00134     
00135      } ;
# fin de si ouverture ok
00136     
00137     
finblockquote() ;
00138     
00139     
######################################################### -->
00140     
00141     
} ; # fin de si
00142     
00143     
pvide() ;
00144     
p
("texte") ;
00145     echo
href
("montresource.php?nomfic=dscbaz.php","Code-source de la page","orange_stim nou")."." ;
00146     
finp() ;
00147     
00148     
finSection() ;
00149     
finblockquote() ;
00150     
finPage() ;
00151     
?>

Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.

 

 

retour gH    Retour à la page principale de   (gH)