Examples of Mysqli multiple queries in php. For more information, see. Mysqli_multi_query (mysqli link, string query) is a process-based msyqli_more_results (mysqli link) that determines whether other result sets are returned. mysqli_next_result (mysqli link) obtain the next result set Example:
- # Connecting to a database
- $ Link = mysqli_connect ("localhost", "root", "root ");
- # Selecting a database
- $ Link-> select_db ("rorely") or die ("cocould not find database ");
- # Querying databases
- If ($ link-> multi_query ("select * from test; select name, age, sex, address from test ")){
- Do {
- $ Result = $ link-> store_result ();
- While ($ row = $ result-> fetch_row ()){
- Echo "$ row [0], $ row [1], $ row [2], $ row [3]
";
- }
- If ($ link-> more_results () echo "**********
";
- } While ($ link-> next_result ());
- }
- $ Link-> close ();
- ?>
Results: 1, Jane, 26, female3, Tome, 21, male4, Lily, 25, female5, Lucy, 25, female6, Jim, 22, male7, Jim, 22, male ********* Jane, 26, female, wenming cun 123 # Tome, 21, male, wenming cun 32 # Lily, 25, female, wenming cun 2 # Lucy, 25, female, wenming cun 2 # Jim, 22, male, wenmin cun 45 # Jim, 22, male, wenmin cun 45 # li, 22, female, wenming cun 23 # hj, 30, male, wenming cun 23 # hj, 30, male, wenming cun 23 # |