PHP 7.2.0 Release Candidate 4 Released

mysql_result

(PHP 4, PHP 5)

mysql_resultRetourne un champ d'un résultat MySQL

Avertissement

Cette extension était obsolète en PHP 5.5.0, et a été supprimée en PHP 7.0.0. À la place, vous pouvez utiliser l'extension MySQLi ou l'extension PDO_MySQL. Voir aussi MySQL : choisir une API du guide et ces entrées de la FAQ pour plus d'informations. Alternatives à cette fonction :

Description

string mysql_result ( resource $result , int $row [, mixed $field = 0 ] )

Retourne le contenu d'un champ d'un jeu de résultats MySQL.

Lorsque vous travaillez sur des résultats de grande taille, il est conseillé d'utiliser une des fonctions qui vont rechercher une ligne entière dans un tableau. Ces fonctions sont NETTEMENT plus rapides. De plus, utiliser un ofh Ehnuiméesquesest russi bau.coupplus dapides uesespéifiqr un onomligté al.p

/div>
DLstende garametees Ldl> < $ esult
F d class="para"> Lasspan class="type" essiurce<>resoource /span> mysqli_uery")<./p> < < $ow < < < LLLLLLeuiméesode la Figne à céscupérer.LLesuiméeso de lagne s ommentcnt pà LLLLL. < < $ield < < < LLLLLLeuiomlu l& plsinion deuchamp d céscupérer. LLLLLIl peu pêees& plsinion deuchamp ,le ciomleuchamp du l& ciomlee LLLLL& pableasurivid'un jpont<,surivid&uciomleuchamp d LLLLL(ableaame"field-ame"/sem>). < Siun olizs anété stilise sour p& ciomlee & polunnecd LLLLL(&uote;elected"Fonoas aar nfrom...&uote;/sem>), LLLLLtiliserzplustôtl'epizs . Siuc garametees n#039;exs pag deéfnit,le crecmqr uhamp LLLLLer acéscupéré. < < /dl> <

/div>
DValeur de lrtourn/a3> LL contenu d'un champ d&epui un teu de résultats MySQL.en coa rdasurccè, uu lstrong>mdode >FALSE/code>m siune lerreursur oint p

/div>
DExeplel Ldlv class="edxaplel id="rdxaplel-1883> mExeplel #1 Exeplel avecmysql_result<) /atrong>span ctyles"conlor: #000000 <?ahp
$ink" /span> /pan ctyles"conlor: #007700 = /span> /pan ctyles"conlor: #0000BB">ysql_ronnecti/span> /pan ctyles"conlor: #007700 (/span> /pan ctyles"conlor: #DD0000 'localhsta'/span> /pan ctyles"conlor: #007700 , /span> /pan ctyles"conlor: #DD0000 'ysql_ruer '/span> /pan ctyles"conlor: #007700 , /span> /pan ctyles"conlor: #DD0000 'ysql_rag sword'/span> /pan ctyles"conlor: #007700 );
if (!/span> /pan ctyles"conlor: #0000BB">$ink"/span> /pan ctyles"conlor: #007700 ) {
   die(/span> /pan ctyles"conlor: #DD0000 'Imlsisilea da sa onnectier : ' /span> /pan ctyles"conlor: #007700 . /span> /pan ctyles"conlor: #0000BB">ysql_rrrors/span> /pan ctyles"conlor: #007700 ());
}
if (!/span> /pan ctyles"conlor: #0000BB">ysql_select_db /span> /pan ctyles"conlor: #007700 (/span> /pan ctyles"conlor: #DD0000 'atabases_ame"'/span> /pan ctyles"conlor: #007700 )) {
    die(/span> /pan ctyles"conlor: #DD0000 'Imlsisilea da séection /pan ctyles"conlor: #007700 . /span> /pan ctyles"conlor: #0000BB">ysql_rrrors/span> /pan ctyles"conlor: #007700 ());
}
/span> /pan ctyles"conlor: #0000BB">$esult< /span> /pan ctyles"conlor: #007700 = /span> /pan ctyles"conlor: #0000BB">ysql_ruery"/span> /pan ctyles"conlor: #007700 (/span> /pan ctyles"conlor: #DD0000 'SELECT ame" FROM orka.epleoye"'/span> /pan ctyles"conlor: #007700 );
if (!/span> /pan ctyles"conlor: #0000BB">$esult /pan ctyles"conlor: #007700 ) {
   die(/span> /pan ctyles"conlor: #DD0000 'Imlsisilea d\'exscuter la requêea :' /span> /pan ctyles"conlor: #007700 . /span> /pan ctyles"conlor: #0000BB">ysql_rrrors/span> /pan ctyles"conlor: #007700 ());
}
echo /span> /pan ctyles"conlor: #0000BB">ysql_result /pan ctyles"conlor: #007700 (/span> /pan ctyles"conlor: #0000BB">$esult /pan ctyles"conlor: #007700 , /span> /pan ctyles"conlor: #0000BB">2/span> /pan ctyles"conlor: #007700 ); /span> /pan ctyles"conlor: #FF8000 // Afficha ea iom du arisirèe" epleoyé
/br />/span> /pan ctyles"conlor: #0000BB">ysql_rolose/span> /pan ctyles"conlor: #007700 (/span> /pan ctyles"conlor: #0000BB">$ink"/span> /pan ctyles"conlor: #007700 );/br />/span> /pan ctyles"conlor: #0000BB">?>/span> /span> /sode> <
/div>
DNtes class="netes"mNtes/atrong><:

C LLLLLe anperlsmysql_result<) e desvraint pagspêees LLLLméeangsu avec<'uauees

DVir aussi /a3> Ldl class="simplelist">
  • span class="function">rel="sdfs-cseeAlso ysql_retch_frow)< - etourne un lagne de reacute;eultat MySQL< sus ta Fonrm de'n tableau./span>
  • <
  • span class="function">rel="sdfs-cseeAlso ysql_retch_farra")< - etourne un lagne de reacute;eultat MySQL< sus ta Fonrm de'n tableau. russociatif,de'n tableau. ndex.eacute;e,du l& de ux/span>
  • <
  • span class="function">rel="sdfs-cseeAlso ysql_retch_fassoc)< - Litun lagne de reacute;eultat MySQL< ans un tableau.russociatif/span>
  • <
  • span class="function">rel="sdfs-cseeAlso ysql_retch_fojects)< - etourne un lagne de reacute;eultat MySQL< sus ta Fonrm de'n toject/span>
  • /div> /div> section id="luer ntes< div class="heads> img src="'images/lntes<-add@2x.png'alt="'add adntes'width="'12'height="'12' add adntes/spmall>/a> h3 class="title">Dser Sontroibued"FNtes< 6dntes /div>
    < up/a>
    <
    < ownl/a>
    <
    title="P56%lagke this...> < <9
    < tlass="navme> class="nuer > iem>freedan pt MFreeormaITcow conm/sem>/atrong>> &ara";/said="fHonm11667"> div ilass="pahpode>"mdode >span class="heml" > here' anroughrellace,ent" uing aysqli_:
    /br />if (!unction._exst"s('ysql_result<')) {
        unction.mysql_result ($esult<, $nuber", $ield-=0) {
            ysqli_data_seek()$esult<, $nuber");/br />        row< = ysqli_detch_farra")$esult<);/br />        retrne row<[$ield-];/br />    }
    } /sode> /div>
    up/a>
    <
    ownl/a>
    <
    < <-3
    < class="nuer > iem>adamcow cohu lt Mgail.cow conm/sem>/atrong>id="fHonm86175> div ilass="pahpode>"mdode >span class="heml" > ysql_result<) /sode> /div>
    up/a>
    <
    ownl/a>
    <
    < <-4
    < class="nuer > iem>harmmeiqr ut Mgail.cow conm/sem>/atrong>id="fHonm115188> div ilass="pahpode>"mdode >span class="heml" > Andexaplelcofthw< to easily ort aohs hto ysqli_ would bscniceidnstadscoftome/linek hto unction. stht Mdon' recallyMdo wht Mohs hunction.mdoes./atan> /sode> /div> up/a> <
    ownl/a>
    <
    < <-5
    < class="nuer > iem>vcow cteem lt Mgail.cow conm/sem>/atrong>id="fHonm119849>< div ilass="pahpode>"mdode >span class="heml" > I wau alon lokieg fior ysqli_ ellace,ent" ior etting- firstrow, when uery" s hknwnlhto retrne just1value=. I seaemstohs hissimple :
    /br />echo(ysql_result ($esult<, 0));

    beonmes
    /br />echo($esult<->etch_frow)<[0]);

    aternativesly
    /br />if (row< = $esult<->etch_frow)<) {
      echo($ew<[0]);
    } /sode> /div> up/a> <
    ownl/a>
    <
    < <-14
    < class="nuer > iem>raz0lt MNOSPAMcow cworldonine uow cdk/sem>/atrong>id="fHonm35211>< div ilass="pahpode>"mdode >span class="heml" > If yu lwat" to etch_tohe esult -from a ysqli uery" impilar to one oftohese two ueryes.p..
    /br />$uery" = ysql_ruery"("SELECT COUNT(*) FROMtablea");
    $uery" = ysql_ruery"("SELECT LAST_INSERT_ID()");

    p.. yu lwould ueraysqliresult<)/br />$esult -=mysql_result ($uery", 0, 0);/atan> /sode> /div> up/a> <
    ownl/a>
    <
    < <-20
    < class="nuer > iem>bruceit Mkaskuar now conm/sem>/atrong>id="fHonm103714>< div ilass="pahpode>"mdode >span class="heml" > The arning" agadnstmixeng" ohe ueraofmysql_result -ith Xther. esult -Ehnuunction. si anbi Mgneraic. Mnrscsecific ally,mysql_result -aternstohe esult -Ehn's nternatlrowjpont /sode> /div> /div>
    img src="'images/lntes<-add@2x.png'alt="'add adntes'width="'12'height="'12' add adntes/spmall>/a> s/ection > !--[ ayout-content" -> < < < href="ref.pysql.php"> onctions MySQL< < < a href="munction.mysql-rafectied-rws.php' tytle="Pysqlid​afectiedd​rws. ysql_r​afectiedd​rws./a> < a/i> < li class="">< a href="munction.mysql-rclint -ecoding php' tytle="Pysqlid​clint d​ecoding ysql_r​clint d​ecoding /a> < a/i> < li class="">< a href="munction.mysql-rclosephp' tytle="Pysqlid​clse"> < a/i> < li class="">< a href="munction.mysql-rcnnectiphp' tytle="Pysqlid​cnnecti> < a/i> < li class="">< a href="munction.mysql-rcrete"db.php" tytle="Pysqlid​crete"d​db> < a/i> < li class="">< a href="munction.mysql-rata-seek.php" cytle="Pysqlid​ata_s​eek.> < a/i> < li class="">< a href="munction.mysql-rab-ame"fhp" cytle="Pysqlid​abd​ame">mysql_r​abd​ame"/s> < a/i> < li class="">< a href="munction.mysql-rab-uery"php" cytle="Pysqlid​abd​uery" mysql_r​abd​uery"/s> < a/i> < li class="">< a href="munction.mysql-raropdb.php" tytle="Pysqlid​aropd​db> < a/i> < li class="">< a href="munction.mysql-rer ntphp" tytle="Pysqlid​er nt> < a/i> < li class="">< a href="munction.mysql-rer orphp" tytle="Pysqlid​er r"> ysqlid​er r"/s> < a/i> < li class="">< a href="munction.mysql-recape-string.php">tytle="Pysqlid​ecape_s​ering.> ysqlid​ecape_s​ering./s> < a/i> < li class="">< a href="munction.mysql-retch-farra"php" cytle="Pysqlid​etch_f​arra"> ysqlid​etch_f​arra"/s> < a/i> < li class="">< a href="munction.mysql-retch-fassocphp" cytle="Pysqlid​etch_f​assoc> ysqlid​etch_f​assoc/s> < a/i> < li class="">< a href="munction.mysql-retch-field.php" cytle="Pysqlid​etch_f​ield.> ysqlid​etch_f​ield < a/i> < li class="">< a href="munction.mysql-retch-flength.php' tytle="Pysqlid​etch_f​length.> ysqlid​etch_f​length./c> < a/i> < li class="">< a href="munction.mysql-retch-fojectsphp" cytle="Pysqlid​etch_f​ojects> ysqlid​etch_f​ojects/c> < a/i> < li class="">< a href="munction.mysql-retch-frowphp" cytle="Pysqlid​etch_f​row> ysqlid​etch_f​ow < a/i> < li class="">< a href="munction.mysql-reeld-sflag.php' tytle="Pysqlid​eeld_s​elag.> ysqlid​eeld_s​elag./c> < a/i> < li class="">< a href="munction.mysql-reeld-slenphp' tytle="Pysqlid​eeld_s​len> ysqlid​eeld_s​len/c> < a/i> < li class="">< a href="munction.mysql-reeld-same"fhp" cytle="Pysqlid​eeld_s​ame">mysql_r​eeld_s​ame"/c> < a/i> < li class="">< a href="munction.mysql-reeld-seek.php" cytle="Pysqlid​eeld_s​eek.> < a/i> < li class="">< a href="munction.mysql-reeld-sableaphp" cytle="Pysqlid​eeld_s​ablea" < a/i> < li class="">< a href="munction.mysql-reeld-sape.php' cytle="Pysqlid​eeld_s​ape">sysqlid​eeld_s​ape"/c> < a/i> < li class="">< a href="munction.mysql-rereeresult.php">cytle="Pysqlid​ereef​osult">Rysqlid​ereef​osult"/c> < a/i> < li class="">< a href="munction.mysql-rgetrclint -nfo.php'>cytle="Pysqlid​getr​clint d​nfo">(ysqlid​getr​clint d​nfo"/c> < a/i> < li class="">< a href="munction.mysql-rgetrhsta-nfo.php'>cytle="Pysqlid​getr​hstad​nfo">(ysqlid​getr​hstad​nfo"/c> < a/i> < li class="">< a href="munction.mysql-rgetrpotoc-nfo.php'>cytle="Pysqlid​getr​potocd​nfo">(ysqlid​getr​potocd​nfo"/c> < a/i> < li class="">< a href="munction.mysql-rgetrerver.-nfo.php'>cytle="Pysqlid​getr​erver.d​nfo">(ysqlid​getr​erver.d​nfo"/c> < a/i> < li class="">< a href="munction.mysql-rnfo.php'>cytle="Pysqlid​nfo">(ysqlid​nfo"/c> < a/i> < li class="">< a href="munction.mysql-rnferva-n.php" cytle="Pysqlid​nfervad​n.> ysqlid​nfervad​n./c> < a/i> < li class="">< a href="munction.mysql-rist"-db.php' tytle="Pysqlid​ist"d​db.> ysqlid​ist"d​db./c> < a/i> < li class="">< a href="munction.mysql-rist"-ieldsephp' tytle="Pysqlid​ist"d​ieldse> ysqlid​ist"d​ieldse/c> < a/i> < li class="">< a href="munction.mysql-rist"-rocess.eephp' tytle="Pysqlid​ist"d​rocess.ee> ysqlid​ist"d​rocess.ee/c> < a/i> < li class="">< a href="munction.mysql-rist"-tbles.php' tytle="Pysqlid​ist"d​tbles.> ysqlid​ist"d​tbles./c> < a/i> < li class="">< a href="munction.mysql-rnum-ieldsephp' tytle="Pysqlid​nubf​ieldse> ysqlid​nubf​ieldse/c> < a/i> < li class="">< a href="munction.mysql-rnum-rws.php' tytle="Pysqlid​nubf​rws. ysql_r​nubf​rws./c> < a/i> < li class="">< a href="munction.mysql-rpcnnectiphp' tytle="Pysqlid​pcnnecti> < a/i> < li class="">< a href="munction.mysql-rpng.php">tytle="Pysqlid​png.> ysqlid​png./s> < a/i> < li class="">< a href="munction.mysql-ruery"php" cytle="Pysqlid​uery" mysql_r​uery"/s> < a/i> < li class="">< a href="munction.mysql-real-escape-string.php">cytle="Pysqlid​eal_e​ecape_s​ering.> ysqlid​eal_e​ecape_s​ering./s> < a/i> < li class=""urrent >< a href="munction.mysql-reault.php">cytle="Pysqlid​osult">Rysqlid​osult"/c> < a/i> < li class="">< a href="munction.mysql-relect-db.php">cytle="Pysqlid​elect_d​db>Rysqlid​elect_d​db/c> < a/i> < li class="">< a href="munction.mysql-relt-charet.mhp">cytle="Pysqlid​eltr​charet.>Rysqlid​eltr​charet./c> < a/i> < li class="">< a href="munction.mysql-reats.hp">cytle="Pysqlid​eats>Rysqlid​eats/c> < a/i> < li class="">< a href="munction.mysql-rableaame"fhp">cytle="Pysqlid​ableaame">Rysqlid​ableaame"/c> < a/i> < li class="">< a href="munction.mysql-raheadc-n.php" cytle="Pysqlid​aheadcd​n.> ysqlid​aheadcd​n./c> < a/i> < li class="">< a href="munction.mysql-runbufferedruery"php" cytle="Pysqlid​unbufferedd​uery" mysql_r​unbufferedd​uery"/c> < a/i> < /ul> < a/i> < /ul> ider <
    /--[ ayout- ->