Performing multiple MySQLi queries in one function using PHP

January 24, 2024


$query = "
SELECT * FROM items WHERE deleted != 'y';
INSERT INTO items(id) VALUES (307);
SELECT * FROM items WHERE id = 307 LIMIT 1;
";

$mysqli -> multi_query($query);

do {

    if ( $result = $mysqli -> store_result() ) {

		  while ( $row = $result -> fetch_assoc() ) {
		        echo $row['id'] . '< br >';
		  }

        $result -> free();
    }

} while ($mysqli -> next_result() );


Comments

There are no comments.


Comment on this Article

Your email address will never be published. Comments are usually approved within an hour or two. (to prevent spam)