I have this following question about different behaviour of result set for SELECT command and INSERT,UPDATE,DELETE command.
My Script:
//Part 1:
$query="Insert into student values($roll,'$name')" ;
$result=mysqli_query($con,$query) or die(mysqli_error($con));
if ($result)
{
$num=mysqli_affected_rows($con);
var_dump($num);
echo $num." rows affected.";
}
//Part 2:
$query1="select * from student";
$result=mysqli_query($con,$query1) or die(mysqli_error($con));
if ($result)
{
$num1=mysqli_num_rows($result);
var_dump($num1);
echo $num1." rows affected.";
}
Following is output for both snippets:
My Question is can't we use mysqli_num_rows($result) for getting number of rows in part1 ?