Answers for "echo query in php"

PHP
17

query sql in php

$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
    }
} else {
    echo "0 results";
}
$conn->close();
Posted by: Guest on February-05-2020
1

php echo sql result

$sql = "select * FROM tableName;";

$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result)) {
  echo $row['columnName']; 
}
Posted by: Guest on August-19-2021
1

php echo sql result

$sql="SELECT * my_table"

$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
    echo $row['fieldname']; 
}
Posted by: Guest on July-03-2021

Browse Popular Code Answers by Language