The simplest way to use the MYSQLi Escape String example looks like this.
<?php
$conn = new mysqli('localhost', 'root', 'pass', 'test');
$srting = "O!-wlearnsmart";
$res = mysqli_real_escape_string($conn, $srting );
echo $res;
?>
In this mysqli_real_escape_string() function allow two-parameter which is a database connection and the other one passes a string. Accordingly, PHP should be used while insert data in the table.
Hence, Keep scrolling down for the next chapter.
mysqli_num_rows() | Check if ResultSet is empty | Example
The simplest way to use check if resultset is empty example looks like this.
<?php
$conn = new mysqli('localhost', 'username', 'password', 'databasename');
$sql = 'select * from tableName';
$query = mysqli_query($conn, $sql );
$rowcount=mysqli_num_rows($query);
print_r($rowcount);
?>
Here, the mysqli_num_rows() function returns the number of rows in the database table in the result set. Accordantly, you have to apply to check how many rows are available. Above all, show this type of example to check MySQLi num rows along with PHP.
mysqli_num_rows() - How to Check if ResultSet is empty
$conn = new mysqli('localhost', 'username', 'password', 'databasename');
$sql = 'select * from TableName';
$query = mysqli_query($conn, $sql );
$rowcount=mysqli_num_rows($query);
if($rowcount > 0){
echo 'Not Empty';
}else{
echo 'Empty';
}
Here, you can see conditions that check if the result set is empty or not. Thus, add this PHP code with the mysqli_num_rows() function example.
Hence, Keep scrolling down for the next chapter.
[wlearnsmartcode]mysqli_fetch_assoc() | Fetch Multiple Rows in PHP | Example
The simplest way to Fetch Multiple Rows in PHP example looks like this.
<?php
$conn = mysqli_connect("localhost", "username", "password", "database-name");
$query = mysqli_query($conn, "SELECT * FROM table-name");
$row = mysqli_fetch_assoc($query);
print_r($row);
?>
In this section, fetch single rows from the database. In the above, the first query to relate connectivity database and another one mysqli_query() this function for run query along with the condition. Thus, the mysqli_fetch_assoc() function use retrieve data from the data then store a variable.
mysqli_fetch_assoc() - How to Fetch Multiple Rown From the Database in PHP
<?php
$conn = mysqli_connect("localhost", "username", "password", "database-name");
$query = mysqli_query($conn, "SELECT * FROM student_table");
while ($row = mysqli_fetch_assoc($query)) {
print_r($row);
}
?>
In this section, you can fetch multiple rows from the database in PHP. Also, this code using a while loop to retrieve data. Therefore, whenever get data to apply this mysqli_fetch_assoc() with a while loop. How to Store and Retrieve Image from database in Php
Hence, Keep scrolling down for the next chapter.
[wlearnsmart]
I am in fact pleased to glance at this web site posts which contains lots of helpful
data, thanks for providing these data.
It’s wonderful that you are getting ideas from this paragraph as well as from our discussion made here.
THis is only for you thanks
Wonderful point to learning thanks…