Develop PHP Website for Learning Web Design Free Online
  Home   |   Forums   |   DevCMS
  Join   |   Log In
 
   

MySQLi Tutorials - Learn MySQLi

Tutor at Develop PHP
Freeing or Closing Query Result Sets Using mysqli_
By: Adam      Created: Jul 15, 2009      Views: 1208 Tweet This Page  Post page to Facebook  Post page to Facebook

Before we get too deep into making queries we should understand how to close result sets by using the mysqli_free_result() function. Freeing result sets helps to open memory and resources associated with a large result set. Even though no errors will occur if you do not use it, it is best to use for performance reasons.

Using mysqli_free_result to free large result sets and resources
Learn HTML
<?php 
// include your MySQL database connection script here
require_once "connect_to_mysql.php";
// Build sql command
$sqlCommand "SELECT username FROM members"
// Execute the query here now 
$query mysqli_query($myConnection$sqlCommand) or die (mysqli_error()); 
// Use mysqli_num_rows to return the count 
$num_rows mysqli_num_rows($query); 
// Output the data here using a while loop
while ($row mysqli_fetch_array($query)) { 
    
// Gather the $row values into local variables
    
$username $row["username"]; 
    
// echo the output to browser 
    
echo "User Name = $username<hr />"

// Free the result set 
mysqli_free_result($query); 
// close mysql connection 
mysqli_close($myConnection); 
?>

Develop PHP browser display window
User Name = Adam
User Name = Joe
User Name = Sally



                                   That concludes this section, to continue learning MySQLi head back to the index


Comment on Freeing or Closing Query Result Sets Using mysqli_




Search Tags:
Freeing   ·  or   ·  Closing   ·  Query   ·  Result   ·  Sets   ·  Using   ·  mysqli_   ·  
 
 
Arbitrary Links and Archives
Home
Active Forums
Members
SIte News
Link To Us
Gear
2009 Forum Archive
Programming Courses
Learn HTML
Learn CSS
Learn PHP
Learn MySQL
Learn Javascript
Learn jQuery
Learn ActionScript 3.0
Learn Java
Learn XML
DevelopPHP Requires Flash Player
Get Adobe Flash player
___________________________________________

Terms of Use  •  Privacy  •  Admin Notes

©2010 developphp.com   |   Powered By FlashBuildingHolder