<?Php
require "config.php";// Database connection file.
$query="select * from student LIMIT 0,5 ";
if ($result_set = $connection->query($query)) {
while($row = $result_set->fetch_array(MYSQLI_ASSOC)){
echo $row['id'],$row['name'],$row['class'],$row['mark']."<br>";
}
$result_set->close();
}
?>
Syntax
$result_set=mysqli_query($connection,$query,MYSQLI_STORE_RESULT);
$result_set=$connection->($query,MYSQLI_STORE_RESULT)
$result_set is FALSE on failure , for SELECT ,SHOW or EXPLAIN we will get mysqli_result object. For other ( successful ) queries we get TRUE as return value.
MySQLI database connection file
By using fetch_array() we get an array of column data as elements. We will get NULL value if there is no more rows in resultset. ( So our while loop will end after going through all rows of returned result set )<?Php
require "config.php";// Database connection file.
$query="select * from student ";
if ($result_set = $connection->query($query)) {
echo "Total No. of records :".$result_set->num_rows;
$result_set->close();
}
?>
Procedural style
<?Php
require "config.php";// Database connection file.
$query="select * from student LIMIT 0,5 ";
if ($result_set = mysqli_query($connection,$query)) {
while($row = $result_set->fetch_array(MYSQLI_ASSOC)){
echo $row['id'],$row['name'],$row['class'],$row['mark']."<br>";
}
$result_set->close();
}?>
$t="SELECT * FROM istudent where mark >90";
$check=$connection->query($t);
if(mysqli_num_rows($check)>0){
// record found
}else{
// No record found
}
$query="UPDATE student SET class='Five'";
if ($connection->query($query)) {
echo "Records Updated";
}else{
echo $connection->error;
}

Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.