Valid XHTML    Valid CSS2    

Listing du fichier combienMysqli.php

 

00001     <?php
00002     
# # (gH) -_- combienMysqli.php ; TimeStamp (unix) : 27 Janvier 2021 vers 16:57
00003     
include("../std.php") ;
00004     
debutPage
(" fonction COMBIEN en PHP / MySQLi ") ;
00005     
h1
("Comptages ") ;
00006     
blockquote() ;
00007     
debutSection() ;
00008     
###################################################
00009     
00010     
function
combien_pas_terrible($cnx,$ndlt) {
00011     
00012     
$res
= $cnx->query("select count(*) from $ndlt ") ;
00013     
$tdr
= mysqli_fetch_array($res) ;
00014      echo
"
$ndlt : ".$tdr["count(*)"]." enregistrements." ;
00015     
00016     }
# fin function combien_pas_terrible
00017     
00018     ###################################################
00019     
00020     
function
combien($cnx,$ndlt) {
00021     
00022     
$cha
= "count(*)";
00023     
$res
= $cnx->query("select $cha from $ndlt ") ;
00024     
$tdr
= mysqli_fetch_array($res) ;
00025      return(
$tdr
[$cha] ) ;
00026     
00027     }
# fin function combien
00028     
00029     ###################################################
00030     
00031     
$cnx
= mysqli_connect("localhost","anonymous","anonymous","statdata") ;
00032     
00033     
combien_pas_terrible
($cnx,"elf") ;
00034     
br() ; ;
00035     
combien_pas_terrible
($cnx,"titanic") ;
00036     
br() ; ;
00037     
combien_pas_terrible
($cnx,"ronfle") ;
00038     
br() ;
00039     
00040     
###################################################
00041     
00042     
$tab
= "ronfle" ;
00043     
$nbe
= combien($cnx,$tab) ;
00044     echo
" il y a
$nbe enregistrements dans $tab " ;
00045     
00046     
###################################################
00047     
00048     
$cnx
->close() ;
00049     
00050     
finSection() ;
00051     
finblockquote() ;
00052     
finPage() ;
00053     
?>

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)