next_result()

PHP mysqli next_result() funksiyasi

❮ PHP MySQLi ma’lumotnomasi

Misol - obyektga yo‘naltirilgan uslub

Ma’lumotlar bazasiga bir nechta so‘rov bajaring:

<?php $mysqli = new mysqli("localhost","my_user","my_password","my_db"); if ($mysqli -> connect_errno) {   echo "Failed to connect to MySQL: " . $mysqli -> connect_error;   exit(); } $sql = "SELECT Lastname FROM Persons ORDER BY LastName;"; $sql .= "SELECT Country FROM Customers"; // Execute multi query if ($mysqli -> multi_query($sql)) {   do {     // Store first result set     if ($result = $mysqli -> store_result()) {       while ($row = $result -> fetch_row()) {         printf("%s\n", $row[0]);       }      $result -> free_result();     }     // if there are more result-sets, the print a divider     if ($mysqli -> more_results()) {       printf("-------------\n");     }      //Prepare next result set   } while ($mysqli -> next_result()); } $mysqli -> close(); ?>

Protsedural uslubdagi misolni sahifa pastida ko‘ring.


ULASHISH

Ta’rif va qo‘llanilishi

next_result() / mysqli_next_result() funksiyasi multi_query() dan keyingi natijalar to‘plamini tayyorlaydi.


Sintaksis

Obyektga yo‘naltirilgan uslub:

$mysqli -> next_result()

Protsedurali uslub:

mysqli_next_result(connection);

Parametr qiymatlari

Parametr Tavsif
connection Majburiy. Foydalaniladigan MySQL ulanishini belgilaydi

Texnik tafsilotlar

Qaytariladigan qiymat: Muvaffaqiyatli bo‘lsa TRUE. Muvaffaqiyatsiz bo‘lsa FALSE
PHP versiyasi: 5+

Misol - protsedural uslub

Ma’lumotlar bazasiga bir nechta so‘rov bajaring:

<?php $con = mysqli_connect("localhost","my_user","my_password","my_db"); if (mysqli_connect_errno()) {   echo "Failed to connect to MySQL: " . mysqli_connect_error();   exit(); } $sql = "SELECT Lastname FROM Persons ORDER BY LastName;"; $sql .= "SELECT Country FROM Customers"; // Execute multi query if (mysqli_multi_query($con, $sql)) {   do {     // Store first result set     if ($result = mysqli_store_result($con)) {       while ($row = mysqli_fetch_row($result)) {         printf("%s\n", $row[0]);       }       mysqli_free_result($result);     }     // if there are more result-sets, the print a divider     if (mysqli_more_results($con)) {       printf("-------------\n");     }      //Prepare next result set   } while (mysqli_next_result($con)); } mysqli_close($con); ?>


❮ PHP MySQLi ma’lumotnomasi

W3Schools Pathfinder

Yutuqlaringizni kuzating – bu bepul!