MySQLi SELECT statement is used to fetch data from the one or more tables. We can retrieve records of all fields or specified fields.
Below the syntax of SELECTstrong> command
SELECT field1, field2,...fieldn FROM table_name [WHERE Clause]
MySQLi SELECT statement is used to fetch data from the one or more tables. We can retrieve records of all fields or specified fields.
Below the syntax of SELECTstrong> command
SELECT field1, field2,...fieldn FROM table_name [WHERE Clause]
<?php
$conn = mysqli_connect('localhost:3306', 'user_name', 'password', 'db_nexladder');
if(! $conn) {
die('Could not connect: ' . mysqli_error());
}
$sql = "SELECT `first_name` FROM `tbl_customers`";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_object($result)) {
echo "Name: " . $row->first_name. "<br />";
}
} else {
echo "0 rows";
}
mysqli_close($conn);
?>
Below it'll look like