Answers for "select data 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
5

get data from select option php

// Page containing a form:
<form action="myaction.php" method="post">
 <select name="fruit">
    <option value="Apple">Apple</option>
    <option value="Banana">Banana</option>
 </select>  
 <input type="submit" value="Submit">
</form>

// myaction.php
Hello <?php echo htmlspecialchars($_POST['fruit']); ?>
Posted by: Guest on June-20-2021
0

php code to select data from mysql database

SELECT column_name(s)
FROM table_name
Posted by: Guest on May-24-2021

Browse Popular Code Answers by Language